Repository navigation
feat(agent-core-v2): add global default for deferred MCP tool disclosure - #4210
Conversation
🦋 Changeset detectedLatest commit: 531fe37 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 567847a318
ℹ️ 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".
| deferredOf(name: string): boolean { | ||
| const entry = this.entries.get(name); | ||
| if (entry === undefined) return false; | ||
| return entry.config.deferred ?? this.options.resolveDefaults?.().defaultDeferred ?? false; |
There was a problem hiding this comment.
Re-register tools when
default_deferred reloads
In an already-open session, changing [mcp].default_deferred through the watched config.toml or /reload updates this resolver but not the disclosure stored in AgentMcpService's existing tool-registry entries. That service only reads resolved().deferred while handling an MCP status event, and no configuration-change event triggers re-registration, so connected servers silently retain the old inline/deferred behavior until they reconnect or the process restarts. Please propagate this setting change to active registrations or explicitly make the setting restart-only instead of resolving it live.
AGENTS.md reference: AGENTS.md:L117-L119
Useful? React with 👍 / 👎.
…ure (MoonshotAI#4210) Ported from MoonshotAI/kimi-code 2.3.0 (f28c51c). Adaptation: kept this fork's one-line `resolved(name: string):` signature in the MCP connection view while replacing `configOf` with upstream's `deferredOf`, and dropped the `McpServerConfig` import that change left unused.
Requirement or Bug
新增
[mcp] default_deferred配置:控制 tool-select 模式下 MCP 工具默认全部 defer,还是按各 server 自己的deferred配置决定。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
默认值解析(唯一解释点,connected 与 needs-auth 共用,在 server (re)connect 时固化到 entry——与 timeout 系配置同一生效时机):
配置下发链路(沿既有 tunables/resolver 模式):
config.toml [mcp] default_deferred McpSectionSchema.defaultDeferred # 新增 zod 字段,无 env 绑定 workspaceMcpConfigService.tunables() - resolveDefaultTimeouts -> McpDefaultTimeouts + resolveDefaults -> McpDefaults (+ defaultDeferred) McpConnectionManager # (re)connect 时 resolveDeferred 捕获到 entry ├─ resolved() → AgentMcpService 注册 connected 工具 └─ AgentMcpService → 注册 needs-auth OAuth 合成工具其他:
docs/config-manifest.toml由gen:config-manifest重新生成;docs/en|zh的config-files.md([mcp]表)与customization/mcp.md(deferred字段行 + 按需加载一节,含生效时机说明)同步;McpDefaultTimeouts/resolveDefaultTimeouts随承载新字段更名为McpDefaults/resolveDefaults(影响面核实限于 agent-core-v2)。Behavior Changes and Affected Users
deferred决定,未配置 = inline[mcp] default_deferred(缺省false),在 server (re)connect 时解析并固化config.deferred ?? false与旧的config.deferred === true逐值等价(true/false/undefined 三态一致),行为不变[mcp] default_deferredconfigOf(name)?.deferred === truedeferredOf,与 connected 路径一致default_deferred的用户:两种状态下 disclosure 不再可能分歧McpConnectionView.configOf移除deferredOfMcpDefaultTimeouts/resolveDefaultTimeouts更名McpDefaults/resolveDefaultsdeferred字段「Defaults tofalse」default_deferred(未设置则为 false),并注明连接时固化受影响模块与测试覆盖:
mcpCore/connection-manager(连接时捕获 +deferredOf):test/mcpCore/connection-manager.test.ts扩展现有用例,覆盖全局默认生效、deferred: falseopt-out、deferredOf,以及「连接后改默认值不影响已注册视图、reconnect 后应用」的固化语义;agent/mcp(注册 disclosure):test/agent/mcp/mcp.test.ts现有 deferred / needs-auth 用例(FakeMcpManager 同步为deferredOf);workspaceMcpConfig(tunables 透出):test/workspace/workspaceMcpConfig/workspaceMcpConfig.test.ts扩展现有用例;corepack pnpm test:886 文件 / 16977 用例全过,零失败)。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.