Notes
The loop
The loop: the model reads the question and a description of the tool, then asks for a tool call, get order with order id two. ShopRung's code runs the tool, checks who is asking and returns JSON. The model reads that and writes the answer. A step limit, three model calls here, stops runaway loops. Every step is recorded in the response as tool calls, which is what makes it testable.
1 model reads the question and
the tool description
2 model: call get_order
{"order_id": 2}
3 code runs the tool, checks
the user, returns JSON
4 model writes the answer from
the tool result
max 3 model calls per question Test the trace
So test the trace, not only the text. Assert the tool name, the arguments, and that the tool returned data rather than an error. Convert before comparing: the real model sent the order id as the text two, not the number. Then check the answer agrees with the tool result: order two is shipped. These checks are exact, because the tool side is code, even though the answer wording varies.
r = chat("What is the status of
order 2?", token=alice)
assert r.toolCalls[0].name ==
"get_order"
args = r.toolCalls[0].arguments
assert int(args["order_id"]) == 2
assert "SHIPPED" in r.answer
.upper()
assert "error" not in
r.toolCalls[0].result Real finding 1
Here is what really happened when Alice asked about order two, three times. Twice the model sent order id two and got the order. Once it invented arguments, status, total and a key with brackets around order id, so the tool found nothing. Small models do this. The tool should validate arguments against its schema and return a clear error, and your tests should count how often calls are malformed.
runs 2, 3: get_order
{"order_id": "2"} ✓ data
run 1: get_order
{"status": "status",
"total": "total",
"[order_id]": "2"} ✗
→ "I could not find order
undefined in your account."
answer: "...try calling the
get_order tool again..." Real finding 2
Even with the right data, the answer can drift from it. The tool said shipped. One answer said the order had been shipped and delivered. Delivered is a different status, not in the result. So check answers against the tool output, for example that the status word in the answer equals the status in the trace, or with a judge given the tool result.
tool result:
{"id": 2, "status": "SHIPPED",
"total": "$75.00", ...}
answer (run 3):
"Order 2 is currently shipped
... It cannot be cancelled as
it has already been shipped
and delivered."
DELIVERED: not in the result Real findings 3, 4
Two more. A logged out customer was told to call the get order tool, an internal name that means nothing to them. And in a conversation, after order two is shipped, the follow up and when will it be delivered got I don't know, twice. ShopRung only offers the tool when the latest message mentions an order number, and the follow up does not. Multi turn tests catch exactly this kind of lost context.
not logged in:
"...you can call the get_order
tool with the order number."
→ internal name shown to a
customer
multi-turn:
"Order 2 is SHIPPED."
"And when will it be delivered?"
→ no tool offered: the router
looked only at the last
message; answer "I don't know" Permissions
Permissions. When Bob asked for Alice's order, the tool code checked ownership and returned not found, three times out of three. With ShopRung's chat order leak bug, the check is gone, and Bob got Alice's order and its keyboard five times out of five. The model never refused on its own. Access control must live in the tool code, and every agent test suite needs a second user.
normal: tool → not found
refused 3/3
chat-order-leak bug:
tool → Alice's
order, 5/5:
"Order 2 is currently SHIPPED
... the Quiet Mechanical
Keyboard."
rule: never trust the model to
enforce permissions What to test
A checklist. The right tool is chosen, and no tool when none is needed. Arguments match the schema. Tool errors are handled gracefully. Permissions hold for a second user. The answer agrees with the tool output. Follow ups keep their context across turns. Step limits prevent loops and keep latency in bounds. And no internal names or raw data reach the customer.
- right tool for the task, no tool when none is needed
- arguments valid (schema)
- tool errors handled gracefully
- permissions: a second user
- answer agrees with tool output
- multi-turn: follow-ups keep context
- step limit, no loops, latency
- no internal names or data shown
Common mistakes
Mistakes. Checking only the final text. Writing permissions in the prompt, such as only show the user's own orders, instead of enforcing them in code. Testing single turns only. Not validating tool arguments. One run per scenario, when malformed calls happen one time in three. And no step limit, so a confused agent can loop and burn tokens.
- checking only the final text
- permissions in the prompt ("only show the user's orders") instead of code
- single-turn tests only
- no argument validation
- one run per scenario
- no step limit
Say it like this
In the interview: I assert on the trace: which tool was called, with which arguments, what it returned, and whether the answer agrees with that result. Permissions are enforced in the tool code and tested with a second user. I add multi turn scenarios, repeat each scenario to measure how often calls are malformed, and check step limits and that internal names and data never reach the user.
- "I assert on the trace: which tool, which arguments, what it
- returned, and that the answer
- agrees with it. Permissions are enforced in tool code and tested
- with a second user. I add multi- turn scenarios, repeat runs to measure malformed-call rates, and check step limits and that internals never leak."