1. Implement an agent loop
hard50 XPWrite run_agent(llm, tools, task, max_steps=5) -> (final_text, messages). llm(messages) returns {"stop_reason": str, "content": [blocks]} where blocks are {"type": "text", "text"} or {"type": "tool_use", "id", "name", "input"}. tools maps name → function(input) -> str. Loop: append the assistant content; if stop_reason is "tool_use", run every tool_use block (unknown tool or exception → is_error: True result) and append one user message containing all tool_result blocks; otherwise return the concatenated text blocks. Raise RuntimeError("step limit") after max_steps LLM calls without finishing.
Ctrl/⌘ + Enter runs the tests · Esc then Tab leaves the editor