reasoning=...controls how much reasoning a model should useevent_streamemits provider reasoning output during streaming when the provider exposes it
on_reasoning_event=... remains available as a callback observer. Thinking
output is not mixed into text_stream, and not every provider exposes the same
kind of data.
1. Control Thinking Depth
Use the top-levelreasoning parameter for portable reasoning controls:
If you need provider-specific options like Gemini
include_thoughts or Anthropic visibility controls, keep using provider_options.
2. Receive Thinking Output While Streaming
Use the typed event stream to receive provider reasoning output in order with text and lifecycle events:on_reasoning_event can still observe the same reasoning events without
consuming the typed stream. text_stream still contains only assistant-visible
text.
ReasoningEvent
Streaming thinking output is delivered asReasoningEvent objects:
summary and delta are both delivered through the same typed stream. They
remain reasoning events, not assistant text, so text_stream, Agent.stream(),
and Agent.chat() do not mix them into the user-visible answer.
Provider Differences
Thinking output is not portable in the same way as assistant text.OpenAI and OpenAI-compatible
- normalized control:
reasoning.effort - output events depend on what the provider actually streams
- ai-query currently looks for OpenAI-compatible fields such as:
delta.reasoning_contentdelta.reasoningdelta.thinkingdelta.thoughtdelta.reasoning_summary
- Responses-style reasoning summaries are emitted as
reasoning.summary
on_reasoning_event will not fire.
- normalized control:
reasoning.budget - visible thought output is provider-specific and should be enabled with:
- ai-query emits
reasoning.deltafor Gemini thought text andreasoning.signaturefor thought signatures
Anthropic
- normalized control:
reasoning.effortandreasoning.budget - ai-query emits
reasoning.deltafor streaming thinking text andreasoning.signaturefor signatures when Claude returns them
Agents
Agents support the same split between reasoning control and thinking output:ReasoningEvent, it also emits an agent event:
chat() and stream() methods still return/yield only assistant text.
Important Guidance
- Do not assume every reasoning-capable model exposes visible thinking output.
- Do not mix reasoning events into user-facing assistant text by default.
- Render
summaryanddeltathrough the same reasoning UI channel unless your product intentionally separates summaries from raw thinking text. - Treat
signatureandstateevents as provider metadata, not natural-language output. - Prefer summaries or explicit UI affordances if you choose to display thinking.