Skip to main content
ai-query treats thinking as two separate concerns:
  • reasoning=... controls how much reasoning a model should use
  • event_stream emits 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-level reasoning parameter for portable reasoning controls:
Current normalized support: 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 as ReasoningEvent objects:
Typical meanings: 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_content
    • delta.reasoning
    • delta.thinking
    • delta.thought
    • delta.reasoning_summary
  • Responses-style reasoning summaries are emitted as reasoning.summary
If a provider only streams final assistant text, on_reasoning_event will not fire.

Google

  • normalized control: reasoning.budget
  • visible thought output is provider-specific and should be enabled with:
  • ai-query emits reasoning.delta for Gemini thought text and reasoning.signature for thought signatures

Anthropic

  • normalized control: reasoning.effort and reasoning.budget
  • ai-query emits reasoning.delta for streaming thinking text and reasoning.signature for signatures when Claude returns them

Agents

Agents support the same split between reasoning control and thinking output:
When an agent receives a ReasoningEvent, it also emits an agent event:
That means thinking output can flow through local callbacks and agent transports such as SSE/WebSocket. The agent’s 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 summary and delta through the same reasoning UI channel unless your product intentionally separates summaries from raw thinking text.
  • Treat signature and state events as provider metadata, not natural-language output.
  • Prefer summaries or explicit UI affordances if you choose to display thinking.

See Also