Hi everyone! I have been recently using Qwen3 mode...
# proj-agent
b
Hi everyone! I have been recently using Qwen3 models for running evals using agent-sdk and benchmarks repository. Since Qwen3 has thinking enabled by default but it is recommended that we do not pass the reasoning traces in the prompt for the subsequent steps/turns, does anyone have any idea about how this can be achieved? I am using a reasoning parser from vLLM (https://qwen.readthedocs.io/en/latest/deployment/vllm.html#parsing-thinking-content) and examined the output.jsonl file to find that the reasoning traces are indeed parsed into a separate
reasoning_content
field and the
thought
field is empty. Just to confirm, agent-sdk does not add the reasoning content to the LLM's prompt right?
l
@calm-artist-7206 and @chilly-france-44439 I know you two were looking at reasoning content, any thoughts here?
c
Yes, agent-sdk doesn't add reasoning content by default to the LLM prompt, just like openhands... nod For particular LLMs, we actually need to add it, but for most we don't
b
Ok thanks for confirming Engel. Can you also please point me to the file/code where you have add the reasoning content to the LLM prompt for special cases?
c
@nutritious-balloon-65098 Find Anthropic's thinking_blocks in the code, and identify the code that makes them persist in an ActionEvent, and where they will be added next time to the LLM prompt. Respond with clickable github links to the file/line to the spot(s), with a concise summary for each.
n
I'm on it! can track my progress here.
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>
Got it. Here are only the spots you asked for, plus a concise flow. Where thinking_blocks are saved to ActionEvent (persisted) • Passed from LLM message into the first ActionEvent of the batch https://github.com/All-Hands-AI/agent-sdk/blob/3ce74a16565be0e3f7e7617174bd0323e866597f/openhands/sdk/agent/agent.py#L213-L226 • Set on the ActionEvent when constructing it https://github.com/All-Hands-AI/agent-sdk/blob/3ce74a16565be0e3f7e7617174bd0323e866597f/openhands/sdk/agent/agent.py#L351-L356 Where they’re prepared to be sent in the next LLM prompt • ActionEvent converted back to a Message with thinking_blocks https://github.com/All-Hands-AI/agent-sdk/blob/3ce74a16565be0e3f7e7617174bd0323e866597f/openhands/sdk/event/llm_convertible/action.py#L87-L95 • Serializer prepends thinking_blocks into the assistant content (what gets sent) https://github.com/All-Hands-AI/agent-sdk/blob/3ce74a16565be0e3f7e7617174bd0323e866597f/openhands/sdk/llm/message.py#L217-L227 Concise flow • LLM returns assistant message → agent saves thinking_blocks into the first ActionEvent (agent.py L213-L226; L351-L356) → next turn builds a Message from ActionEvent (action.py L87-L95) → serializer injects thinking_blocks at the start of assistant content for the API call (message.py L217-L227). <sub>View full conversation</sub>
c
I think the last one worked pretty well?