Anthropic plugin drops thinking blocks between tool calls
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- machine-learning, python
調査の方向性
Start in livekit-plugins-anthropic by tracing where thinking, redacted_thinking, thinking_delta, and signature_delta events are handled and where FunctionCall.extra is serialized. Use the issue's agent reproduction and request logging to verify that thinking blocks are replayed unchanged before tool results. The change is complete when blocks are restored while the system prompt, tools, and earlier messages are unchanged, but omitted after a prefix change without causing a 400.
索引モデルが issue の本文から書いたものです。
説明
Bug Description
livekit-plugins-anthropic ignores the thinking events in the stream (thinking and redacted_thinking blocks, thinking_delta, signature_delta). The blocks never reach the chat context, so the request that carries a tool result goes without the reasoning that led to the tool call.
The API does not return an error for this. The model silently loses its reasoning and starts again in the middle of a tool loop. Anthropic's docs make this a requirement (Preserving thinking blocks):
Required: within a tool-use turn, pass thinking blocks back.
This now affects agents that never asked for thinking: Claude Haiku 5.5, Sonnet 5.5, Opus 5 and Opus 5.5 think by default (adaptive). #6868 notes the same gap ("thinking blocks are not kept in the chat context, so a turn carrying a tool call is replayed without them") and leaves it out of scope.
Expected Behavior
The thinking blocks of a response that calls a tool go back, unchanged, before that tool_use block in the following requests.
There is one catch for a fix. A thinking block's signature is bound to the system prompt, the tools and the earlier messages. On accounts created on or after 2026-08-31, the API rejects a block with a 400 when that prefix changed, and update_instructions() and update_tools() change it in the middle of a session:
messages.1.content.0: Invalid `signature` in `thinking` block. The block is bound to a different conversation. Remove the block, or set `thinking.block_binding.prefix_mismatch_behavior` to "drop_block". The `system` prompt differs from the one this block was created with.
So a fix must also stop sending a block after its prefix changed.
Reproduction Steps
1. Run an agent with anthropic.LLM(model="claude-haiku-5-5") and one function tool.
2. Ask something that makes the model call the tool.
3. Log the request that carries the tool result: the assistant turn has only the tool_use block.
Direct API check with claude-haiku-5-5 (anthropic 0.125.0, effort low), same tool step:
- tool result, thinking block kept: 200, 601 input tokens
- tool result, thinking block stripped: 200, 525 input tokens (the reasoning is gone, no error)
- block kept, system prompt then edited, with
thinking.block_binding.prefix_mismatch_behavior="error"
(what a new account gets by default): 400 (message above); the same for an added tool
Operating System
macOS 26.6.2
Models Used
Claude Haiku 5.5 (claude-haiku-5-5) through livekit-plugins-anthropic
Package Versions
livekit-agents==1.8.3, and main at ceb3d59
livekit-plugins-anthropic==1.8.3, and main at ceb3d59 (1.8.8 is the same)
anthropic==0.125.0
Proposed fix
A PR follows: it keeps the blocks in FunctionCall.extra["anthropic"] (the field that carries Gemini thought signatures) with a hash of the request prefix, and puts them back only while that prefix is unchanged.
- 主要言語
- Python
- スター
- 14.6k
- フォーク
- 3.9k
- 平均マージ
- 3日 20時間
- マージ済み PR(30日)
- 193
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
livekit/agents のほかの issue
-
Assistant markup is stripped from chat history when expressive mode is off対応中かも @ShivamSharma43 が 14 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
docs: openai.LLM vs openai.responses.LLM for HTTP OpenAI-compat hosts再び着手できるかも @AbarnaaSree が 53 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
livekit/agents#7022 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
livekit/agents#8031 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Agent stays "speaking" forever when the avatar participant leaves mid-reply対応中かも @regalmoix が今日担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 54/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
comp/tools P2 type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NousResearch/hermes-agent#142908 · コメント 1 件 ·
-
[oblt-aw][autodoc] Fix malformed headings in new Buildkite docs pages対応中かも @github-actions が今日担当しました。 オープンdocumentation
難易度 1/5 1時間未満 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: fileUploadMatrix.test.ts URL case does a real DNS lookup and fails offline対応中かも @r2jaff が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ComposioHQ/composio#5054 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
pytorch/tensordict#3286 ·
メンテナーはふだん 1 日以内に返信