provider.api_error: unload_tools rejected — "tool is not declared or has already been unloaded" — session unrecoverable

未关闭
#5,492 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript

调研方向

Start by tracing how context compaction rebuilds request history and preserves dynamic_tool_schema messages, then follow how unload_tools directives are validated against provider tool state. The issue points to #5066 as related; compare its findings with a long session using MCP servers and dynamic tool loading. Done means compaction cannot leave unload directives inconsistent and the session can continue after compaction.

由索引模型根据 Issue 内容生成。

描述

What version of Kimi Code is running?

2.8.0

What platform is your computer?

Linux (WSL2)

What model were you using?

Default Kimi model with dynamically_loaded_tools capability.

What issue are you seeing?

Every turn in the session fails with:

Error: [provider.api_error] unload_tools at message position 88:
tool "<mcp tool name>" is not declared or has already been unloaded

The request history contains an unload_tools directive that the provider-side load/unload state machine rejects. Once it appears, every subsequent request is rejected with the same error — the session cannot continue, only starting a new session helps.

Notably, dynamic tool loading was active even though tool-select is NOT enabled under [experimental], no MCP server has deferred: true, and no KIMI_CODE_EXPERIMENTAL* env vars are set.

Likely related to #5066 (compaction drops dynamic_tool_schema messages): if compaction rebuilds history while unload directives remain, the wire history can end up inconsistent with the provider-side state machine.

Steps to reproduce
  1. Long session with MCP servers, dynamic tool loading active.
  2. Context compaction occurs (auto-compaction in a long session).
  3. Next request fails with the error above; every retry fails identically.
Expected behavior

The client should keep load/unload directives consistent with the provider state machine (or rebuild them after compaction), and a session should never enter a state where every request is rejected.

Also reported via /feedback, Feedback ID 3611.

主要语言
TypeScript
星标
8.3k
派生
1.4k
平均合并
12 小时 6 分钟
30 天内合并 PR
596

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

MoonshotAI/kimi-code 的其他 Issue

查看 MoonshotAI/kimi-code 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。