Repository navigation
Description
The Anthropic provider keeps only the text and the tool_use blocks of a response, so a turn of the assistant that calls a tool goes back, with the result of the tool, without the thinking blocks that it had.
What happens
AnthropicResponseParser(src/providers/anthropic/anthropic_response_parser.cpp) reads thetextandtool_useblocks ofcontent. Athinkingor aredacted_thinkingblock is not kept anywhere.- The request builder of the provider writes an assistant turn from the text and the tool calls, and has nothing to write such a block back from. The next request, the one with the
tool_result, has the turn of the assistant astextandtool_useonly.
Why it matters
The current Claude models think when the request says nothing about it. From https://platform.claude.com/docs/en/build-with-claude/thinking: with no thinking field, Claude Opus 5.5, Claude Sonnet 5.5, Claude Haiku 5.5, Claude Fable 5.2 and the other models of the table there run with adaptive thinking, and "display defaults to "omitted" on these models", so the response has thinking blocks with an empty thinking field and a signature. The provider does not send a thinking field, so this is what an ordinary request to the default models gets.
The same page says what to do with these blocks: "Preserving thinking blocks: when you return tool results, you must pass the thinking blocks from the assistant message back to the API, complete and unmodified", and "Required: within a tool-use turn, pass thinking blocks back."
What is not known
What the API does with a turn that lacks its thinking blocks was not checked against the API. The page says "To preserve model quality, the API might strip thinking blocks that would create an invalid turn structure, or disable thinking when the conversation history is incompatible with thinking being enabled", so it may be that the request is answered and the model continues without the reasoning that led to the call, and not that it is refused.
A way to fix it
The same as in #75 for the Bedrock provider, and as the Gemini and the OpenAI Responses providers do with their thought signatures and reasoning items: the parser returns a turn that has thinking blocks in GenerateResult::response_messages with the blocks as ProviderContentParts in their place, and the request builder writes them back as they came. The multi-step loop and the applications that append response_messages to the conversation then replay them without a change. The stream needs a look as well: whether a tool loop over a stream has a place to keep the blocks.
Where it was found
In the review of the Bedrock provider for ClickHouse, which found the defect in that provider: ClickHouse/ClickHouse#137792 (comment). The Anthropic provider has it since before that pull request; when it was introduced was not determined.
Related: #75
Related: ClickHouse/ClickHouse#137792
Activity
Send the reasoning of a model of Amazon Bedrock back with the tool re…
alexey-milovidov commentedon Dec 6, 2026
One more thing for whoever fixes this, found in the same review (ClickHouse/ClickHouse#137792 (comment)).
A
thinkingblock is valid only in the conversation that it was made in: "A prefix check fails ifsystem,tools, or an earlier message changed after Claude produced a block" (https://platform.claude.com/docs/en/build-with-claude/preserved-thinking/prefix-checks), with a 400 error for the newest models and a possible one for the others. So once the provider returns these blocks, an application that trims its history or builds the system prompt or the tools again must remove them from the messages that it keeps: "you can leave out the oldest, the newest, or all of them, but not one in between". Today the provider drops the blocks, so no application can run into this.anthropicprovider this way (AIClientFactory::bindsReasoningToConversationin Add Amazon Bedrock as a provider of the AI agent of the client ClickHouse#137792), so it needs no change when this is fixed.