CONCEPT The server runs its own loop
Some tools — server-side tools like web search and code execution — run on
Anthropic's infrastructure, not in your code. When the model uses one, the server enters its
own sampling loop (roughly ~10 iterations), calling the tool and feeding results back to the model
without any round-trip to you. If that internal loop is still going when a limit is reached, the response comes
back with stop_reason == "pause_turn".
pause_turn means "I'm not done, but I paused." Your job is to let the server
resume — re-send the assistant turn as-is and call again. The server picks up where it left off.| Aspect | Client-side tool (2.2) | Server-side tool (this page) |
|---|---|---|
| Runs where | Your code | Anthropic infra |
| Stop signal | tool_use | pause_turn (when its loop pauses) |
| What you send back | A user turn with tool_result | The assistant turn as-is (no tool_result, no new user text) |
| Who loops the tool | You | The server (~10 iters) |
"Continue." user message. That injects a new user
turn and derails the resume. Re-send the same assistant content and call the API again.DIAGRAM Pausing and resuming a server-side tool
loop (~10 iters)"} B -->|finished| C["🟢 stop_reason == end_turn → done"] B -->|paused| D["🟣 stop_reason == pause_turn"] D --> E["append response.content
(assistant turn) AS-IS"] E --> F{"continuations < cap?"} F -->|Yes| G["call messages.create again
NO 'Continue.' user msg"] G --> B F -->|No| H["🔴 stop: hit continuation cap"] classDef done fill:#d4edda,stroke:#28a745,color:#155724; classDef pause fill:#e2d4f0,stroke:#764ba2,color:#3d1a5b; classDef stop fill:#f8d7da,stroke:#dc3545,color:#721c24; class C done; class D,E,G pause; class H stop;
CODE The pause_turn branch (resume, capped)
Re-send the assistant content unchanged, and cap the number of continuations so a runaway server loop can't spin forever.
# Server-side tools (web search, code execution) run on Anthropic infra. messages = [{"role": "user", "content": question}] resp = client.messages.create( model="claude-opus-4-8", max_tokens=4096, tools=[{"type": "web_search_20250305", "name": "web_search"}], messages=messages, ) MAX_CONTINUATIONS = 5 continuations = 0 while resp.stop_reason == "pause_turn": if continuations >= MAX_CONTINUATIONS: break # cap runaway loops # Re-send the assistant turn AS-IS. No "Continue." user message! messages.append({"role": "assistant", "content": resp.content}) resp = client.messages.create( model="claude-opus-4-8", max_tokens=4096, tools=[{"type": "web_search_20250305", "name": "web_search"}], messages=messages, ) continuations += 1 # Server resumed until it finished → now handle end_turn (or another reason).
response.content, call again, repeat while
pause_turn, with a continuation cap. The server does the tool work; you just keep the loop
turning.TRADE-OFFS Server-side tools vs. client-side tools
✅ Server-side (pause_turn model)
- Anthropic runs the tool loop — less orchestration code
- Fewer round-trips to your service per sub-step
- Built-in capabilities (search, code execution)
⚠️ Costs / caveats
- You must handle
pause_turnand cap continuations - Less direct control over each tool step
- A wrong "Continue." message breaks resumption
EXAM TRAPS
"Continue." user message on pause_turn. → Wrong.
Re-send the assistant turn as-is; the server resumes. A new user message derails it.pause_turn like tool_use and sending a
tool_result. → Server-side tools already ran on Anthropic infra; there's no client
tool_result to supply. Just resume.pause_turn means the model is finished. → It is the
opposite — it paused mid-work and expects to be resumed.PRACTICE
Q1 · You get pause_turn after enabling web search. What exactly do you send next?
Append response.content as an assistant turn (unchanged) and call
messages.create again with the same tools. No "Continue." user message and no
tool_result — the server resumes its own loop.
Q2 · Why cap continuations on pause_turn?
The server-side loop can pause repeatedly. Without a cap (e.g. 5) a pathological run could keep pausing and resuming, burning tokens and latency. The cap bounds the worst case.
Q3 · How is handling pause_turn different from handling tool_use?
tool_use: you run the tool and reply with a user tool_result.
pause_turn: the server already ran the tool on Anthropic infra; you just re-send the assistant
turn as-is so it resumes. Different roles, different payloads.