What are reasoning tokens?
When models with reasoning capabilities process a prompt, they generate two distinct types of content:- Reasoning blocks: the model’s internal chain-of-thought, problem decomposition, and step-by-step analysis
- Text blocks: the final, polished response presented to the user
AIMessage, accessible via the contentBlocks property:
Not all models produce reasoning tokens. This pattern applies specifically to models that support extended thinking or chain-of-thought output. Standard chat models return only text blocks.
Use cases
- Transparency: show users the model’s reasoning process to build trust in its answers
- Debugging: inspect the model’s thought process to identify where it goes wrong
- Educational tools: teach students problem-solving by revealing how an AI approaches questions
- Decision support: let domain experts validate the reasoning behind recommendations
- Quality assurance: audit reasoning chains for compliance in regulated industries
Extracting reasoning and text blocks
ThecontentBlocks array on an AIMessage contains all blocks in the order they were generated. Filter them by type to separate reasoning from text:
Accessing messages from useStream
Define a TypeScript interface matching your agent’s state schema and pass it as a type parameter to useStream for type-safe access to state values. In the examples below, replace typeof myAgent with your interface name:
Building a ThinkingBubble component
TheThinkingBubble presents reasoning tokens in a visually distinct, collapsible container. Users can expand it to see the full thought process or collapse it to focus on the final answer.
Styling the ThinkingBubble
Differentiate reasoning blocks from regular messages with a distinct visual treatment:Streaming indicator for reasoning
While the model is still generating reasoning tokens, show an animated indicator to communicate that thinking is in progress:Rendering the complete AI response
Combine theThinkingBubble and a standard text bubble into a single AIResponse component:
Handling edge cases
Messages without reasoning
Not every AI message will contain reasoning blocks. WhencontentBlocks has only text blocks, render a standard message bubble without the ThinkingBubble.
Empty reasoning blocks
Some models produce empty reasoning blocks as placeholders. Filter these out:Multiple reasoning-text cycles
A single message can alternate between reasoning and text blocks. If you need to preserve this interleaving, iteratecontentBlocks in order rather than grouping by type:
Best practices
- Default to collapsed: show reasoning on demand, not by default
- Show character count: gives users a quick sense of how much thinking went into the response
- Differentiate visually: use distinct colors, borders, or backgrounds so reasoning is never confused with the actual answer
- Animate transitions: smooth expand/collapse animations improve perceived quality
- Consider accessibility: use proper ARIA attributes (
aria-expanded,aria-controls) on the toggle button - Truncate in previews: show a short preview of the reasoning when collapsed so users can decide whether to expand
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

