capstone — ship the system11 / 12
wire it all together — a cli agent in 12 steps
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:
- Runs at most
MAX_TURNSiterations. - Calls
fake_llm(messages). - If
stop_reason == "end_turn", prints the text and breaks. - 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
⌘↵ runs the editor.
Booting Python…
Output
[promptdojo:~]$ _