promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_

Wire it all together — a CLI agent in 12 steps — step 12 of 12

Checkpoint

One last thing before we move on. pass this to mark the lesson done, or skip and keep moving. hop to the next when you're ready.

Last one. The starter has a complete agent — fake LLM, tool registry, the loop, and a log_lines list for the trace. The loop is wired to exit after the LLM returns end_turn. Right now the script prints the final answer but doesn't log a single thing — log_lines ends empty.

Add two log_lines.append(...) calls inside the loop so that:

  1. After every LLM response, you append a JSON string of {"turn": turn, "stop_reason": response["stop_reason"]}.
  2. After every successful tool call, you append a JSON string of {"turn": turn, "tool": block["name"], "result": result}.

Then the script prints the count of log entries.

Expected output:

done. todos: write tests
log entries: 3

full-screen editor opens — close anytime to keep reading.