promptdojo_

Build the full agent loop. The starter has:

  • fake_llm(messages) — returns hardcoded responses based on history length (1 message → tool_use, 3 messages → end_turn).
  • run_tool(name, args) — handles tool dispatch.
  • MAX_TURNS = 5 — the loop guardrail.
  • messages = [...] — initial user prompt.

Write the agent loop that:

  1. Runs at most MAX_TURNS iterations.
  2. Calls fake_llm(messages).
  3. If stop_reason == "end_turn", prints the text and breaks.
  4. If stop_reason == "tool_use", runs the tool, then appends two messages — the assistant's tool_use, and a user message wrapping the tool_result.

Expected output:

done. todos: write tests

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.