An internal assistant lets an LLM call tools: search the wiki, fetch a URL, send an email. The step runner trusts whatever the model prints: fenced JSON crashes it, invalid arguments reach the tools, retries are missing, spend is unbounded and a fetched web page can make it send email. Make the runner robust.
This is the practice version. Assessments always use a variant you have never seen.
Last week the assistant emailed a customer list to an address it found on a fetched web page. agent/runner.py:run_step(llm, messages, budget) asks the model for one tool call,
parses it (agent/parse.py), validates it (agent/schema.py) and runs the tool (agent/tools.py). agent/llm.py
is a scripted stand-in for the model with real token pricing.
json, JSON), a sentence before the JSON,
text after it. Reject anything that is not a single valid call with ParseError.TOOLS (required, no unknown keys, types, enums) → ValidationError.ToolCallError.budget.remaining_usd
(raise BudgetExceeded); retries count.role == "tool" and trusted == False, a tool with side_effects=True
must return PendingConfirmation instead of running.| Fix the Retrieval Layer of a Support RAG BotAI/LLM engineeringTiers: JuniorEditorial | Medium | Code repo | 50 min | Calibrating |