A scratchpad is temporary external storage for intermediate information produced during an agent’s task. It acts as working memory: the agent writes plans, events, or partial results, then rereads them on later steps to maintain continuity across calls. section 5.4
A scratchpad does not think or reason by itself. It stores and tracks the outputs of an agent’s thinking. The agent remains responsible for interpreting, revising, and using those entries. section 5.4.1
Use a scratchpad when an agent needs to:
- Break a complex task into steps and preserve intermediate results. section 5.4
- Review and revise a global plan as individual goals are completed. section 5.4
- Carry information between fresh invocations, preventing earlier events from disappearing. section 3.4
- Support ReAct or tree-of-thought workflows when suitable instructions define how the stored thoughts are used. section 5.4.1
A time-tracking journal
A time-travel agent can call record_event to append each event to a journal and call load_journal to retrieve the entries before producing a summary. A module-level in-memory list is sufficient for a single-agent, single-process demonstration, but the same shared list has different correctness properties when multiple agents connect to one server. section 3.4
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)
Inspect a minimal MCP configuration that exposes the SequentialThinking tool to an agent, lists its tools, and runs a planning request. section 5.4.1
