promptdojo_
Checkpoint

One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.

Final drill. Build a research agent with three tools and parallel tool calls. Write run_research_agent(question, max_iterations) that:

  • Maintains a messages list, starting with one user turn.
  • Loops up to max_iterations times, calling fake_model(messages).
  • On end_turn: return {"ok": True, "answer": <text>, "rounds": <iterations used>, "tools_called": <total tool runs across all turns>}.
  • On tool_use: handle ONE OR MORE tool_use blocks per turn. For each, dispatch through TOOLS. If the tool name isn't in the registry, the tool result content should be "unknown tool: <name>" (don't crash). Each tool you successfully run counts toward tools_called. Append the assistant turn + one user turn with all tool_result blocks.
  • If max_iterations is exhausted without end_turn: return {"ok": False, "answer": "capped", "rounds": max_iterations, "tools_called": <count so far>}.

Two cases run for you. Expected output:

ok=True rounds=3 tools=3 answer=found 2 sources on ramen
ok=False rounds=2 tools=2 answer=capped

this step needs the editor

on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.

open this same url on a laptop to keep going today.