Overview
Chain of Thought (CoT) mode forces the LLM to break problems into explicit reasoning steps before arriving at a final answer. Instead of generating a response in a single pass, the model produces a structured reasoning trace — showing its work step by step — and then synthesizes a final answer from that trace. CoT significantly improves accuracy on tasks involving math, logical reasoning, multi-factor decisions, and complex analysis. It requires no additional LLM calls beyond Standard mode (the reasoning happens within a single generation), making it a free accuracy upgrade for many use cases.How It Works
Inject Reasoning Instructions
Based on the selected strategy, reasoning instructions are injected into the prompt. For example, “Let’s think step by step” for the
step_by_step strategy.Generate Reasoning Trace
The LLM generates a detailed reasoning trace, with each step emitted as a
cot_step SSE event. The reasoning is visible to the client in real time.Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_mode | string | — | Must be "chain_of_thought" |
cot_config.strategy | string | "step_by_step" | Reasoning strategy (see below) |
cot_config.max_steps | number | 5 | Maximum number of reasoning steps |
cot_config.show_reasoning | boolean | true | Whether to include the reasoning trace in the response |
Strategies
CoT mode offers four reasoning strategies, each suited to different problem types.- Step by Step
- Question Breakdown
- Pros and Cons
- Custom
step_by_step
The most general strategy. The model solves the problem one logical step at a time, building toward the answer incrementally.Prompt injection: “Let’s solve this step by step. For each step, clearly state what you are doing and why.”Best for: Math problems, algorithmic reasoning, sequential processes.SSE Events
Chain of Thought mode emits these events during execution:| Event | When | Payload |
|---|---|---|
node_started | Node begins | { node_id, node_type } |
cot_step | Each reasoning step is generated | { step_number, content, node_id } |
llm_token | Each token is generated | { token, node_id } |
llm_finished | Generation completes | { node_id, total_tokens } |
node_finished | Node completes | { node_id, status } |
cot_step event is unique to Chain of Thought mode. Clients can use it to display the reasoning trace progressively as the model works through the problem.
Showing vs. Hiding Reasoning
Theshow_reasoning parameter controls whether the reasoning trace is included in the final response:
| Value | Behavior | Use Case |
|---|---|---|
true | Full reasoning trace + final answer | Educational tools, debugging, transparency |
false | Final answer only (reasoning is still generated but not shown) | Production assistants where users want just the answer |
Even with
show_reasoning: false, the reasoning trace is still available in the node’s execution metadata for debugging and logging. It simply is not included in the user-facing response.Performance Characteristics
| Metric | Chain of Thought |
|---|---|
| LLM calls per execution | 1 (same as Standard) |
| Additional latency | Moderate (longer generation due to reasoning steps) |
| Token usage | 1.5-3x Standard (reasoning trace adds tokens) |
| Quality improvement | Significant for reasoning tasks |
Example: Financial Analysis Workflow
When to Use Chain of Thought
| Scenario | Recommendation |
|---|---|
| Simple factual Q&A | Use Standard — CoT adds unnecessary verbosity |
| Math and calculations | Use CoT (step_by_step) — significant accuracy improvement |
| Multi-factor decisions | Use CoT (pros_cons) — structured evaluation |
| Complex research questions | Use CoT (question_breakdown) — systematic coverage |
| Creative writing | Use Standard or Reflection — CoT reasoning is less useful for creative tasks |
Best Practices
Match strategy to problem type
Match strategy to problem type
Use
step_by_step for sequential/mathematical problems, question_breakdown for multi-part questions, pros_cons for comparisons, and custom for domain-specific frameworks.Increase max_tokens for CoT
Increase max_tokens for CoT
The reasoning trace consumes tokens. Set
max_tokens to 2-3x what you would use in Standard mode to ensure the model has space for both reasoning and the final answer.Use lower temperature
Use lower temperature
CoT works best with lower temperature (0.1-0.4) to keep the reasoning focused and consistent. Higher temperatures can cause the model to meander in its reasoning.
Set appropriate max_steps
Set appropriate max_steps
The
max_steps parameter prevents excessively long reasoning chains. For most tasks, 5-10 steps is sufficient. Very complex problems may benefit from 15-20 steps.