Agent harness
Anthropic ML engineer candidates report a tooling scenario in which the model plans and then calls a tool (1 report). In an OpenAI round billed as system design, the questions turned to an agent harness and its evals (1 report). It starts like this:
An agent is a model that calls tools in a loop. The model only writes text. Your code runs the tools.
Write
run_agent(model, tools, task, max_steps=10). The transcript starts with the user's task. Each step callsmodel(transcript), which returns{"answer": text}or{"tool": name, "args": {...}}. For a tool call, runtools[name](**args), and add the call and its result to the transcript. Stop on an answer, or aftermax_stepsmodel calls. Return a dict with theanswer, why itstopped("answer"or"max_steps"), and thetranscript.For the task
"Can I return order A17?":
- The model asks for
look_up_orderwith the args{"order_id": "A17"}. The loop runs it, and adds the call and its result,"A17: 2-person tent, delivered Nov 10, $189.00, unused".- The model returns
{"answer": "A17 can be returned."}. The loop adds the answer and stops.So
run_agentreturns the answer"A17 can be returned.",stoppedset to"answer", and a transcript of 4 messages. Withmax_steps=1, the model never gets its second turn: the answer isNone,stoppedis"max_steps", and the transcript holds 3 messages.
Then the levels come. Errors go back to the model as results, not crashes: a tool that doesn't exist, a tool that raises, arguments that don't fit the tool's schema. Then a person approves risky calls, and a run that makes the same call three times in a row stops as a loop. The follow-ups ask about budgets, a refund that must never run twice, and how you grade an agent.
You don't write it yet. This lesson builds each piece first on one example, a shop's returns agent: the loop, tool definitions, errors and limits, a person for risky calls, and grading. At the end you solve the whole problem, level by level, in an interview simulation with a 45-minute timer.
This is the newest kind of coding round: a loop around a model. Hold on to one idea from the start. The loop is plain code that owns every decision, and the model only suggests the next call.