promptdojo_

Build the actual agent loop. Write run_agent(question) that:

  • Starts with a messages list containing one user turn with question.
  • Loops up to 5 times. Each iteration calls fake_model(messages).
  • If response["stop_reason"] is "end_turn", return the text from response["content"][0]["text"].
  • If it's "tool_use", append the assistant turn AND a user turn containing a tool_result with content="42" (we'll pretend every tool returns 42). Then loop again.
  • If the cap is hit without end_turn, return the string "capped".

Then call it once and print the result.

Expected output:

the answer is 42

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.