The SequentialThinking tool is a callable scratchpad for tracking an agent’s reasoning. It accepts structured JSON describing operations, but it does not think or reason independently. section 5.4.1
Use it when a problem needs multiple steps, changing plans, preserved context, filtering, or course correction. Unlike an autonomous reasoner, it records thought steps while the agent decides what to do. section 5.4.1
A practical reasoning loop looks like this:
- Record a reasoning step with the SequentialThinking tool. section 5.4.2
- Call an action tool when the next step requires external work. section 5.4.2
- Observe the result, then record another thought to decide whether to continue or finish. section 5.4.2
- Adjust the planned number of thoughts, revise earlier thoughts, or add further thoughts when the problem changes. section 5.4.1
Time-travel agent
An agent solving a time-travel riddle uses SequentialThinking before selecting travel_back or travel_forward. Traces reveal repeated reasoning, action, observation, and reasoning again—the ReAct pattern. The tool can structure the process, but the model may still produce a wrong answer. section 5.4.2
Listing 5.9 04_sequential_thinking_agent.py
thinking_srv = MCPServerStdio( #1
name="sequential-thinking",
params={
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-sequential-thinking"
],
},
)
instructions = """
You are helpful planning assistant.
"""
agent = Agent(
name="Assistant",
instructions=instructions,
mcp_servers=[thinking_srv], #2
)
async with thinking_srv:
tools = await thinking_srv.list_tools()
print("Available tools:", tools) #3
goal = """
Discover and output the tool and functions you have available.
"""
print("Running...", goal)
result = await Runner.run(agent, goal)
print(result.final_output)
Shows the smallest MCP stdio setup: attach the sequential-thinking server to an agent, list available tools, and run a planning request. section 5.4.1
