Wire it all together — a CLI agent in 12 steps — step 12 of 12
One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.
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:
- After every LLM response, you append a JSON string of
{"turn": turn, "stop_reason": response["stop_reason"]}. - 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
One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.
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:
- After every LLM response, you append a JSON string of
{"turn": turn, "stop_reason": response["stop_reason"]}. - 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
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.