Repository navigation
Description
你运行的 Kimi Code 版本是?
2.6.0
你使用的是哪个开放平台/订阅?
Kimi Code 订阅
你使用的是哪个模型?
K3.1 Pro(kimi-code/k3.1-pro)
你的电脑平台是?
Linux 7.2.15-arch1-1 x86_64 unknown
你遇到了什么问题?
从 2.5.3 升级到 2.6.0 后,新会话中的部分 MCP 工具不会进入实际发给模型的工具列表,导致 Agent 无法调用这些工具。
表面上可能表现为 Agent 不再遵循 AGENTS.md 中关于主动使用 MCP 的指令,但排查后确认,AGENTS.md 已正确加载,MCP 服务器也已成功连接;实际问题是工具定义在模型请求装配阶段被遗漏。
在一个受影响的 2.6.0 会话中:
- 三个启动较慢的 MCP 服务器均成功完成工具发现,共计发现 92 个工具。
tool_select.initialized包含 126 个工具,其中包括上述全部 92 个 MCP 工具。- 但
llm.tools_snapshot只有 34 个工具,上述 92 个工具全部被省略。 - 启动较快、在会话初始化前完成发现的其他 MCP 工具则正常保留。
- 会话同时收到:
No tools are currently available for dynamic loading in this session. - 后续没有出现包含缺失工具的
<tools_added>公告,因此也无法通过select_tools加载。 - 缺失状态在后续 Turn 中不会自动恢复。
执行 /mcp 并等待所有服务器显示已连接,再提交第一条 prompt,也不能解决问题。此时会话的模型工具基线已经固定,/mcp 不会重建该基线。
关闭 tool-select 同样无效。
复现步骤?
- 配置多个 stdio MCP 服务器,其中至少一个需要数秒才能完成初始化和工具发现。
- 不为这些服务器设置
deferred。 - 启动一个新会话并立即提交 prompt。
- 检查该会话的
agents/main/wire.jsonl。 - 在异常会话中可以观察到以下顺序:
- 记录
turn.prompt - 较慢的 MCP 服务器随后记录
mcp.tools_discovered tool_select.initialized包含这些较晚发现的工具llm.tools_snapshot却不包含这些工具
- 记录
- 后续请求仍不会恢复这些工具。
仅提交“回复 OK”之类不需要调用工具的 prompt,即可检查实际工具列表。
在相同机器、相同配置和相同 MCP 服务器下进行版本对照。两个版本中,较慢的 MCP 都是在 turn.prompt 之后、llm.tools_snapshot 之前完成发现:
- 2.5.3:
llm.tools_snapshot包含 124 个工具,较晚发现的 MCP 工具全部存在。 - 2.6.0:
llm.tools_snapshot只有 34 个工具,这些 MCP 工具全部缺失。 - 2.6.0 关闭 tool-select:只有 32 个工具,这些 MCP 工具仍全部缺失。
问题发生在模型请求装配阶段,因此应该与具体模型和具体 MCP 服务器无关。
期望的行为是什么?
会话不应在初始 MCP 发现尚未完成时永久固定一个不完整的工具基线。
可以考虑以下任一行为:
- 在初始化会话工具基线前,等待初始 MCP 发现达到稳定状态,包括 connected、needs-auth、disabled 或明确失败;或
- 将初始化后发现的工具正确作为运行时新增工具处理,并在支持动态加载时通过
<tools_added>公告。
成功连接的 MCP 服务器不应在整个会话中对模型保持不可见。
补充信息
该回归可能由 #4630(refactor(agent-core-v2): port agent loop runtime core)引入。
2.6.0 的 AgentLoopService.initializeLoop() 会通过 requestFactory.baselineTools() 获取工具,并将其保存到 loop.state.profile.tools,但该初始化过程没有等待 MCP 就绪。
后续 /mcp 只显示 MCP 状态,不会重建这个已经保存的基线。
2.5.3 的 createToolSelectResolver 在 prepareForRequest() 后,当 request.profile.tools 未定义时使用 toolSelect.defaultTools(disclosure)。2.6.0 改为将已有的工具基线传给 toolSelect.requestTools(...);如果基线在 MCP 发现完成前生成,较晚发现的工具就不会进入模型请求。
受影响的会话中,动态工具公告也是空的,因此没有通过 select_tools 恢复的路径。
目前确认有效的临时处理只有回退到 2.5.3。以下操作均无效:
- 在第一条 prompt 前执行
/mcp并等待全部服务器 connected - 在异常会话中继续等待或提交后续 Turn
- 关闭 tool-select
相关但不完全相同的旧问题:#3442。该 issue 报告的是旧版本 /reload 后的 MCP readiness 竞争;本问题发生在 2.6.0 普通新会话的 Agent Loop 初始化路径,并附有 2.5.3/2.6.0 的直接对照。
Contribution
- 我愿意自己提交修复此 bug 的 PR(请先等待维护者在本 issue 中批准)
Activity
ilyavasilenko89 commentedon Nov 14, 2026
I reproduced the incomplete MCP tool baseline on
mainatf082f04a093a3e71a2263c5461d52507dc31f83a, using the in-repository test harness with no credentials, external sites, or real model requests.This also matches a Windows 11 report on CLI 2.6.1: Playwright MCP connects and registers 25 tools;
tool_select.initializedcontains 52 tools, butllm.tools_snapshotcontains only 26 built-ins, with neithermcp__playwright__*norselect_tools. Setting[experimental] tool-select = falsedoes not recover the missing tools. Those counts describe the affected session; the reproduction below uses one synthetic MCP tool.Reproduced scope and cause
The isolated reproduction specifically covers disabled progressive disclosure, for both
inlineanddeferredMCP registrations. It does not establish the effective flag/capabilities of the original Windows session or prove every enabled-disclosure path in this issue.AgentLoopService.initializeLoop()capturestoolSelect.initialTools()before initial MCP discovery has finished.AgentToolSelectService.requestTools()starts from the earlier baseline and adds only schemas already loaded in message history. The newly completed initial catalog does not reach the request.Relevant code: loop initialization, request tool selection.
The same
requestTools()implementation is present in the official@moonshot-ai/[email protected]tag (30e3ce442ae850a7461b80f2ce209cd73a301d02). This path was introduced by #4630. The installed CLI was not modified or used for these tests.Minimal reproduction
After installing the repository dependencies, save the following two files. Tested with Node.js 24.19.0 and pnpm 10.33.0 on Windows. The test registers the synthetic tool after Loop initialization and before the first request, isolating the discovery timing boundary without requiring an MCP transport.
packages/agent-core-v2/.tmp/issue/reproduce.test.ts:packages/agent-core-v2/.tmp/issue/vitest.config.ts:Run from the repository root:
Both cases fail on the stated baseline: the catalog assertion passes, but the actual request contains
['Read']instead of['mcp__example__echo', 'Read']. There are no real model calls or credentials involved.Related work
This is distinct from #2381 / #2384, which concern activation of
select_tools. The activation policy has already been addressed in merged #3667. The reproduction above deliberately disables disclosure, so restoringselect_toolsactivation cannot fix it.A first local attempt to append the complete initial catalog in every fallback request was rejected during review: it broke the same-profile fork invariant restored by #4832. The revised patch below preserves that invariant.
Revised local patch
The Loop completes its initial tools once, after startup MCP discovery and before the first model request, and records the completed baseline in its existing
tools.settledstate. Agent creation remains non-blocking. Only missing initial MCP definitions are added; existing definitions and built-in tools remain pinned. An explicitly inherited baseline bypasses this completion step, so a same-profile fork does not acquire additional tools from its own fresh catalog.When progressive disclosure is unavailable, definitions already in that baseline are sent inline, including deferred definitions. Previously loaded schemas retain precedence for deferred tools. The patch does not merge the live catalog into every request or change configuration defaults or persistence formats.
Validation on the stated base, on 2026-11-14:
inline/deferred× disabled flag/unsupported model) fail with the original production sources and pass with the patch./btwafter both startup and runtime discovery. Startup tools are inherited; a server connecting after the parent's first request does not widen the child's baseline. The original runtime-fork review counterexample now passes too.Lookupsnapshot are covered.coreandagent-core-v2; import-boundary checks passed. Type-aware lint: 0 errors; pre-existing warnings remain, with none on added lines.All reproduction data is synthetic. Tests use the repository harness and a local loopback MCP server, with no credentials or external sites. The diff is provided below for review; no commit, push, or PR has been created. Would maintainers approve a focused bug-fix PR for #4904 with this approach?
Local patch, including regression tests and changeset
Aleksey-Forest commentedon Nov 16, 2026
kimi-code-mcp-issue-4904-wire-logs-min.zip
Confirming the same bug on macOS, CLI v2.6.0, provider
managed:kimi-code(Kimi For Coding plan). Reproduced 2x; three wire.jsonl sessions attached
(wire.jsonl, wire-1.jsonl, wire-2.jsonl).
Identical signature to the report above:
mcp.tools_discoveredfires for all 4 MCP servers at startup;tool_select.initializedregisters 102 tools including 75mcp__*andselect_tools.llm.tools_snapshotcontains only 26 builtin tools — zeromcp__*,no
select_tools— and stays that way for the whole session (~10 min observed).Data points that may help narrow it down:
recompute the snapshot inconsistently: one switch produced a correct
101-tool snapshot ~10 minutes in; in another session an
mcp__call onlysucceeded after switching away and back.
(
k3-256k,kimi-for-coding-highspeed) get the full 101-tool schema —so the issue is not provider-wide.
MCP discovery events land ~1s later. Consistent with the race described here.
model alias on the same provider without
dynamically_loaded_toolsstillreproduces (not a config-level capability issue);
[experimental] tool-select = falsedoes not recover the tools (matches the note above).
No reliable user-side workaround found so far. Happy to test the revised
patch or provide more logs.
xxchan commentedon Nov 18, 2026
Still present in 2.6.3, and it also affects the ACP path (
kimi acp,session/newwith an HTTP MCP server), not only interactive sessions.Isolated controls, fresh
HOME/KIMI_CODE_HOME, local OpenAI-compatible provider, no real account or model. One HTTP MCP server delays its firsttools/listreply by exactly 1000 ms; everything else is immediate; deferred loading off. The session then waits before prompting and sends two prompts:tools/listdelayOn 2.6.3 the wire shows
mcp.tools_discoveredandtool_select.initializedcontaining the tool while both providertoolsarrays omit it, the same signature as above. Waiting after discovery and before the first prompt does not help. Source reading on the 2.6.3 tag (b0de2fbd) agrees with the analysis here:initializeLoop()storesrequestFactory.baselineTools()before MCP readiness is joined inmcpService.ts, and nothing replaces that baseline afterwards.This is separate from #5036 (MCP configuration replaced on resume).
AI-assisted report from the OAR project's runtime tests; measurements and source references as stated above.
Agent Cindy wrote this for @xxchan through Stamp (grant
cgr_ac42b22a2ac64436db46020f9fd977e8)namuda commentedon Nov 19, 2026
Independent reproduction and version bisection on Windows 11 (kimi-code win32-x64), confirming this regression and narrowing it down:
kimi -pwith a 5s-delay MCP serverllm.tools_snapshotSo the regression landed in 2.6.0 exactly as analyzed above, and is still present in the latest canary (2026-11-18).
Additional data points from our sessions (
agents/main/wire.jsonl, 2.6.3):kimi -p(print mode), the freeze happens very early — beforeturn.prompt. A fast MCP server that completes discovery beforechangeNotifier.snapshotis included; anything slower is excluded even whenmcp.tools_discoveredis recorded well beforellm.tools_snapshot:llm.tools_snapshot(472 MCP tools after a lategodot-mcp-prodiscovery). So the interactive path has some per-request rebuild, while the print/headless path does not. Print mode (CI) is therefore the most severely affected surface.Workaround we're using meanwhile: a local HTTP MCP shim that answers
initialize/tools/listinstantly from a cached schema (HTTP transport connects in-process, so it wins the race againstchangeNotifier.snapshot) and proxiestools/callto the real stdio server. Works reliably inkimi -pon 2.6.3. Posting here in case it helps others; the proper fix is of course not freezing the baseline before initial MCP discovery settles.test: require bridged tools to actually run, and xfail Kimi Code 2.6 (#…
keros68 commentedon Nov 21, 2026
在 Windows 11 + Kimi Code 2.7.2 + kimi-cu-win 0.3.6 + Node.js 24.19.0 上确认,当前 npm 最新版仍复现,使用真实模型
kimi-code/k3.1-pro和真实 KimiCU MCP 调用验证。版本对照(同一台机器、同一插件和配置,均为全新
kimi -p会话):llm.tools_snapshot为 42 个工具,包含 KimiCU 的 3 个工具;实际js → kimiCU.list_windows()成功。mcp.tools_discovered已记录plugin-kimi-cu-win:win的js、js_reset、js_add_node_module_dir,tool_select.initialized为 43 个工具,但首轮llm.tools_snapshot只有 39 个,KimiCU 全部缺失,模型因此报告没有js工具。作为本地诊断,将最新
defaultToolsForDisclosure()中缺失的工具合并进请求后,2.7.2 首轮恢复为 42 个工具并实际调用 KimiCU 成功。这里仅将其作为根因验证,不建议把每次请求合并完整目录作为正式修复;已看到上面关于 same-profile fork invariant 的说明。希望优先评估并合入前面更完整的 startup baseline 修复方案。test: expect Kimi Code's bridged-tools test to pass again (#277)