Skip to main content

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

1

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.
2

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.
3

Extract Final Answer

The final answer is extracted from the end of the reasoning trace and returned as the node’s output.

Configuration

{
  "type": "ai-agent-node",
  "config": {
    "agent_mode": "chain_of_thought",
    "model": "gpt-4o",
    "system_prompt": "You are a math tutor. Always show your work.",
    "cot_config": {
      "strategy": "step_by_step",
      "max_steps": 10,
      "show_reasoning": true
    },
    "temperature": 0.3,
    "max_tokens": 8192
  }
}
ParameterTypeDefaultDescription
agent_modestringMust be "chain_of_thought"
cot_config.strategystring"step_by_step"Reasoning strategy (see below)
cot_config.max_stepsnumber5Maximum number of reasoning steps
cot_config.show_reasoningbooleantrueWhether to include the reasoning trace in the response

Strategies

CoT mode offers four reasoning strategies, each suited to different problem types.

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.
{
  "cot_config": {
    "strategy": "step_by_step",
    "max_steps": 10
  }
}
Example output:
Step 1: Identify the known values.
- Principal: $10,000
- Annual rate: 5%
- Time: 3 years

Step 2: Apply the compound interest formula.
A = P(1 + r)^t = 10000(1 + 0.05)^3

Step 3: Calculate.
A = 10000 × 1.157625 = $11,576.25

Step 4: Find the interest earned.
Interest = $11,576.25 - $10,000 = $1,576.25

Final Answer: The compound interest earned over 3 years is $1,576.25.

SSE Events

Chain of Thought mode emits these events during execution:
EventWhenPayload
node_startedNode begins{ node_id, node_type }
cot_stepEach reasoning step is generated{ step_number, content, node_id }
llm_tokenEach token is generated{ token, node_id }
llm_finishedGeneration completes{ node_id, total_tokens }
node_finishedNode completes{ node_id, status }
The 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

The show_reasoning parameter controls whether the reasoning trace is included in the final response:
ValueBehaviorUse Case
trueFull reasoning trace + final answerEducational tools, debugging, transparency
falseFinal 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

MetricChain of Thought
LLM calls per execution1 (same as Standard)
Additional latencyModerate (longer generation due to reasoning steps)
Token usage1.5-3x Standard (reasoning trace adds tokens)
Quality improvementSignificant for reasoning tasks
The key insight is that CoT uses the same number of API calls as Standard mode. The extra cost comes only from the additional tokens generated for the reasoning trace. This makes it the most cost-effective way to improve accuracy.

Example: Financial Analysis Workflow

{
  "agent_mode": "chain_of_thought",
  "model": "gpt-4o",
  "system_prompt": "You are a financial analyst. When asked to evaluate an investment, analyze the financials thoroughly and provide a clear recommendation.",
  "cot_config": {
    "strategy": "pros_cons",
    "max_steps": 8,
    "show_reasoning": true
  },
  "temperature": 0.3
}

When to Use Chain of Thought

ScenarioRecommendation
Simple factual Q&AUse Standard — CoT adds unnecessary verbosity
Math and calculationsUse CoT (step_by_step) — significant accuracy improvement
Multi-factor decisionsUse CoT (pros_cons) — structured evaluation
Complex research questionsUse CoT (question_breakdown) — systematic coverage
Creative writingUse Standard or Reflection — CoT reasoning is less useful for creative tasks

Best Practices

Use step_by_step for sequential/mathematical problems, question_breakdown for multi-part questions, pros_cons for comparisons, and custom for domain-specific frameworks.
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.
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.
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.

Next Steps