Skip to content

fix: clear config defaults via delete-capable replace writes - #1830

Closed
liruifengv wants to merge 1 commit into
mainfrom
fix/config-section-clear-via-replace
Closed

fix: clear config defaults via delete-capable replace writes#1830
liruifengv wants to merge 1 commit into
mainfrom
fix/config-section-clear-via-replace

Conversation

@liruifengv

Copy link
Copy Markdown
Collaborator

Related Issue

None — the problem is explained below. (Found while reviewing #1824.)

Problem

In the agent-core-v2 daemon, removing the default provider or logging out of the managed OAuth account is supposed to clear the dangling defaults (default_provider, or default_model + thinking). The code called IConfigService.set(section, undefined) for those clears — but set() deep-merges, and for a scalar section its deepMerge resolves an undefined patch back to the existing base value (patch ?? base), so the "cleared" value is written straight back. In production the stale default survives forever; the unit tests passed only because their config stub assigns undefined directly.

What changed

  • ProviderService.delete: clear defaultProvider via config.replace() instead of config.set().
  • AuthService OAuth-logout cleanup: clear defaultModel and thinking via config.replace() instead of config.set().
  • replace() is the delete-capable write path: an explicit undefined removes the section from the persisted config (stripEnv → undefined → delete), which is exactly the semantic these call sites need.
  • Tests: updated call-site assertions (setreplace), extended the auth test's configReplace stub to the two cleared sections, and added a live-ConfigService test pinning the contract — set(undefined) keeps the value, replace(undefined) deletes it — so the real merge semantics are covered, not just the stub behavior.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my fix works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b2e2f44

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@liruifengv liruifengv closed this Jul 17, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b2e2f4455d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +67 to +68
// `set()` cannot delete: its deepMerge resolves an undefined patch back
// to the existing base value. `replace()` removes the section instead.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove inline comments from agent-core-v2 code

packages/agent-core-v2/AGENTS.md requires comments in this subtree to live only in the top-of-file header block and says to never place comments beside functions, methods, or statements. This newly added explanatory inline comment violates that scoped rule (the same pattern is repeated in the auth and test changes), so the diff won't meet the package's review standards; move the context to the file header if it is still needed, or delete it.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant