Skip to main content
The thinking layer adds an explicit reasoning phase before the agent produces its final response. The agent first analyzes the user’s request, plans its approach, and identifies which tools to use — then executes with that plan guiding the response.

Quick Start

With thinking=True, the agent makes two model calls:
  1. Thinking call — analyzes the request and produces a compact plan
  2. Main call — generates the response guided by the plan

How It Works

When thinking is enabled, the agent:
  1. Builds a context-aware thinking prompt that includes:
    • A summary of the agent’s instructions (first 500 characters)
    • A catalog of available tools (name + one-line description)
    • Flags for whether knowledge base or memory context is available
  2. Calls the model with this prompt and a compact structured output schema (ThinkingOutput)
  3. Injects a brief <analysis> tag (~20-50 tokens) into the system prompt before knowledge and memory context
  4. Runs the main model call with the plan guiding how it uses available context
The thinking plan is positioned before knowledge and memory in the system prompt, so it frames how the model uses retrieval content rather than competing with it.

System Prompt Order

Configuration

Custom Model

Use a separate (potentially cheaper or faster) model for the thinking phase:

Custom Instructions

Override the context-aware prompt with a fully custom thinking prompt:
Custom instructions bypass the context-aware prompt building entirely. The thinking model will not receive tool names, agent instructions, or context availability flags.

Disable

Thinking Reference

bool
default:"true"
Whether thinking is active. Always True when instantiated directly.
Model
Model to use for the thinking phase. If None, uses the agent’s model.
str
Custom thinking prompt. If None, uses the context-aware prompt builder which includes tool catalog, agent instructions summary, and context availability flags.
str
default:"always"
When to activate thinking. "always" runs every call; "auto" does a lightweight model pre-check and only activates thinking when the query is judged complex; "never" disables even if configured.
str
Description shown in the layer guide injected into the system prompt. If None, uses the default description for the thinking layer.

Output

The thinking phase populates three fields on RunOutput:

Streaming

The thinking phase streams in real time. Events are emitted in this order:

Context-Aware Thinking vs Model-Native Reasoning

Definable supports two types of reasoning that can coexist: Both can be active simultaneously. The thinking layer populates reasoning_steps and reasoning_messages, while model-native reasoning populates reasoning_content.

Testing

Use MockModel with structured_responses to test the thinking phase without API calls:
When tool_plan is provided in the thinking output, the reasoning steps include a “Tool Plan” step listing the planned tool sequence. This is useful for testing that the thinking phase correctly identifies which tools to use.