kimi-code icon indicating copy to clipboard operation
kimi-code copied to clipboard

ACP resume advertises initial MCP tools after connections are replaced

Open xxchan opened this issue 2 weeks ago • 1 comments

What version of Kimi Code is running?

2.6.3 (@moonshot-ai/[email protected]), with the same current results on 2.6.2. A prior direct comparison first observed this on 2.5.0 and passed on 2.4.1. The current source audit pins tag @moonshot-ai/[email protected], commit b0de2fbd2de04d87689225aafd3912e5d193b62d.

Which open platform/subscription were you using?

No subscription or real account. An isolated OpenAI-compatible provider on loopback returns deterministic tool calls. Both MCP servers are local echo fixtures. Credentials are synthetic test markers.

Which model were you using?

aimock-model, the scripted local provider. No real model requests.

What platform is your computer?

Linux x86_64, Node.js 24.19.0. The direct invocation results below were not measured on macOS or Windows.

What issue are you seeing?

After closing a CLI and resuming its ACP session in a fresh process, the provider's tool declarations keep the MCP names from the original open, while actual execution uses the current resume configuration. A model can therefore choose a removed tool, and cannot discover newly supplied names from the advertised list.

Resume MCP input Provider tools Actual invocation
Omitted Original mcp__echo__echo, mcp__remote__echo Both return Tool "..." not found
Empty array Same original pair Both return Tool "..." not found
Same names, new server configuration Original names Both execute with the new synthetic credentials
New names newstdio and newhttp Original names; new names missing Old calls fail; explicitly scripted new names execute with new credentials

Example native tool result delivered to the provider:

<system>ERROR: Tool execution failed.</system>
Tool "mcp__echo__echo" not found

All prompt responses have stopReason: "end_turn", including turns with failed tool calls. This report concerns declaration correctness, not retention of removed connections or credentials.

What steps can reproduce the bug?

  1. Start kimi acp with an isolated home and local OpenAI-compatible provider.
  2. Send initialize, then session/new with stdio server echo and HTTP server remote. Call both echo tools and finish the turn.
  3. Stop that CLI process, keeping the isolated native session state.
  4. Start a new kimi acp, initialize, then session/resume with that session ID and the same working directory. Test the four MCP inputs in the table on independent seeded sessions.
  5. Inspect the provider's first tools array. Have the scripted provider call both old names and, for the renamed case, both new names, then inspect the actual tool results.

The reusable direct ACP script does not import an OAR runtime adapter: probe and original investigation. In an OAR checkout with its locked dependencies installed:

npm install --prefix /tmp/kimi-263 @moonshot-ai/[email protected]
node --import tsx experiments/kimi-mcp-resume/native.ts /tmp/kimi-263/node_modules/.bin/kimi /tmp/kimi-263-results

The output contains exact ACP frames, provider requests, stderr, isolated native state and a report. Session IDs are disposable fixture identifiers; context percentage is not needed to reproduce this catalog mismatch. The current run completed all eight turns per version and all expected tool outcomes. Current selected evidence and source discussion are in botiverse/oar.

What is the expected behavior?

After a fresh-process resume, advertise the tools that are currently callable, including newly supplied names and excluding removed names. If retaining the initial catalog is intentional, the protocol needs a supported way to refresh it or a model-visible update that accurately describes current availability.

Additional information

The inspected source is consistent with the observed separation:

  • ACP restore passes current MCP options. Materialization uses them for current connections.
  • Durable initial tools preserve the original snapshot across restore.
  • Declaration selection falls back to an initial entry when it is absent from the current registry, while new non-runtime entries do not enter that initial set.

No supported catalog reset was found in the inspected ACP model/mode/thinking options or documented configuration. Experimental deferred loading requires a model capability and was not enabled in these measurements. A previous one-expression diagnostic on 2.5.0 changed declaration selection and aligned it with execution, but it is not a proposed production patch: caching and native dynamic loading semantics need maintainer review.

This AI-assisted report is based on inspected source and measured native traffic. Per CONTRIBUTING.md, this is an issue for direction first; no native patch or PR is being submitted without maintainer approval.

Contribution

  • [ ] I am willing to submit a PR for this bug fix myself (please wait for maintainer approval in this issue first)

Agent Cindy wrote this for @xxchan through Stamp (grant cgr_ac42b22a2ac64436db46020f9fd977e8)

xxchan avatar Nov 18 '26 04:11 xxchan

I'd like to work on this. I checked the tool selector on main in isolation and confirmed that it still returns the old MCP tool name when the live registry removes or renames it.

PR #5011 looks related. It addresses tools discovered late during startup. Would you prefer to handle changes to the MCP server list on session/resume separately? If so, could a maintainer /approve this issue? I'd start with an ACP regression test that resumes a session with a renamed server and checks the tool names sent to the model.

GooseKIller avatar Nov 20 '26 00:11 GooseKIller