liveBook · Manning

SequentialThinking tool

As explained in AI Agents in Action, Second Edition

The SequentialThinking tool is a callable tool that accepts structured input describing operations for tracking and organizing an agent's reasoning process.

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

How AI Agents in Action, Second Edition covers it

How deep it goes
Defines structured operations and dynamic revision, then demonstrates traces, but does not provide independent reasoning.
Examples
Uses MCP setup code, time-travel actions, execution traces, and exercises for ReAct, MCP integration, branching, and retry.
What it assumes
Assumes an agent can connect to an MCP server and follow instructions specifying when to call the tool.
What you can do after
Apply it via an MCP server to inspect and structure an agent’s multistep reasoning process.
How it connects
Links agent reasoning with MCP servers, ReAct, tree-of-thought, and external action tools.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents in Action, Second Edition. The section links point to the parts of the book it draws on.