Summary of where Anthropic thinking_blocks are handled and how they flow
1. Definition and ingestion
• Models: ThinkingBlock and RedactedThinkingBlock
<https://github.com/All-Hands-AI/agent-sdk/blob/3ce74a16565be0e3f7e7617174bd0323e866597f/openhands/sdk/llm/message.py#L64-L88
Typed> representations for Anthropic’s extended-thinking blocks.
• Message.thinking_blocks field
<https://github.com/All-Hands-AI/agent-sdk/blob/3ce74a16565be0e3f7e7617174bd0323e866597f/openhands/sdk/llm/message.py#L164-L168
Carries> Anthropic thinking blocks on each assistant message.
• Ingest from LiteLLM → Message
<https://github.com/All-Hands-AI/agent-sdk/blob/3ce74a16565be0e3f7e7617174bd0323e866597f/openhands/sdk/llm/message.py#L292-L338
Extracts> thinking_blocks from the provider message and converts them to the typed models.
2. Persistence on ActionEvent
• ActionEvent schema (field)
<https://github.com/All-Hands-AI/agent-sdk/blob/3ce74a16565be0e3f7e7617174bd0323e866597f/openhands/sdk/event/llm_convertible/action.py#L28-L31
Stores> thinking_blocks from the assistant turn that triggered tool calls.
• Populated when building ActionEvent(s)
<https://github.com/All-Hands-AI/agent-sdk/blob/3ce74a16565be0e3f7e7617174bd0323e866597f/openhands/sdk/agent/agent.py#L219-L226
On> tool-calling responses, the first ActionEvent in the batch receives thinking_blocks from the LLM message.
• Preserved across multi-tool-call batches
<https://github.com/All-Hands-AI/agent-sdk/blob/3ce74a16565be0e3f7e7617174bd0323e866597f/openhands/sdk/event/base.py#L142-L148
When> combining multiple ActionEvents (same response), thinking_blocks from the first are retained.
3. Added back into the next LLM prompt
• ActionEvent → Message conversion (includes thinking_blocks)
<https://github.com/All-Hands-AI/agent-sdk/blob/3ce74a16565be0e3f7e7617174bd0323e866597f/openhands/sdk/event/llm_convertible/action.py#L87-L95
ActionEvent.to_llm_message> returns a Message embedding thinking_blocks.
• Serialization: injected at start of assistant content
<https://github.com/All-Hands-AI/agent-sdk/blob/3ce74a16565be0e3f7e7617174bd0323e866597f/openhands/sdk/llm/message.py#L217-L227
Message._list_serializer> appends the thinking_blocks first in the assistant message content for Anthropic’s interleaved-thinking.
• Prompt assembly and final formatting path
Build Messages from Events:
https://github.com/All-Hands-AI/agent-sdk/blob/3ce74a16565be0e3f7e7617174bd0323e866597f/openhands/sdk/agent/agent.py#L169
Serialize for transport (calls to_llm_dict):
https://github.com/All-Hands-AI/agent-sdk/blob/3ce74a16565be0e3f7e7617174bd0323e866597f/openhands/sdk/llm/llm.py#L760-L778
In short: thinking_blocks are captured from the provider response into Message, persisted on the first ActionEvent in a tool-call batch, and then added at the beginning of the next assistant message’s content when serializing the prompt for the subsequent LLM call.
<sub>
View full conversation</sub>