AITraining2U

Programs

Resources

Case Studies

Quick Links

Enquire Now
Core Domain 1 · Agentic Architecture & Orchestration ~35 min

Handle pause_turn and resume a server-side tool

Resume a long-running server tool correctly instead of restarting it.

Server-side tools like web search can run past a single turn. The API returns stop_reason "pause_turn" to say the turn is unfinished, not failed. Build a client that resumes it, and prove to yourself the difference between resuming and starting over.

What to build

  1. Enable a server-side tool (web search) and send a query broad enough to take multiple rounds.
  2. Detect stop_reason "pause_turn" specifically — not as a fallback in an else branch.
  3. Resume by sending the paused response's content back unmodified as the next assistant turn.
  4. Continue until stop_reason becomes "end_turn".
  5. Instrument the loop: count resumptions and total tokens per resumption.

Done when

  • pause_turn is handled as its own branch alongside tool_use and end_turn.
  • The paused content is echoed back verbatim — nothing is regenerated or summarised.
  • The run completes without ever re-issuing the original user message.
  • You can explain why mutating the paused content breaks resumption.

If you want to go further

  • Add a resumption cap and a clean fallback message when it is exceeded.

The trap this exercise teaches

Treating pause_turn as an error and retrying from the top. That discards completed work, doubles cost, and can loop indefinitely on a slow tool.

Before you start

The theory behind this build is covered in pause_turn and server-side tools. If any step below is unfamiliar, read that first — the exercise assumes it. Primary source: Claude Docs — Tool use.

Check yourself against the exam

This exercise sits in Domain 1, which is 27% of the CCAR‑F exam. Once you have built it, run a domain drill in the study app and see whether the questions read differently.