Topic 4
Step through a trace
Here's the loop on a concrete task: a customer says they were charged twice. The agent has three tools: list_charges and get_policy, which only read, and refund, which moves money. The trace is written by hand to show the shape; no model was run.
Predict first
A support agent, step by step
Illustrative trace · tools: list_charges, get_policy (read), refund (write)
step 1 of 11
Model calls
0
Tool calls
0
Write actions
0
Task
I was charged twice for order 4417. Can you refund the duplicate?
Everything above the current step is in the model's context when it produces the next one. The model only writes text; the harness parses each tool call, runs it and appends the result.
Things to notice as you step:
- The context grows. The last model call reads the task, three thoughts, three calls and three results. On a long task, that growth becomes the problem of lesson 3.
- Arguments come from results.
ch_2and49aren't in the task; the agent read them from the first tool result. AI Engineering (Ch. 6, "Plan generation") notes that parameter values are often extracted from earlier tool outputs, and that the model frequently has to guess when information is missing. - The policy check is a choice. Nothing forced the agent to call
get_policybeforerefund. If it had skipped it, the refund would have gone through anyway. Lessons 2 and 6 are about making checks like this structural instead of hoping for them. - One step is different.
refundis a write action. If the harness retried it after a timeout, the customer might be refunded twice. That's lesson 4.
Quick check