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

オープン
#5,492 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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分
マージ済み PR(30日)
596

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

MoonshotAI/kimi-code のほかの issue

MoonshotAI/kimi-code の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。