When a model can call tools, the failure mode is no longer “it answered poorly.”
It becomes:
- it called the wrong tool
- it called the right tool with the wrong parameters
- it called a tool without the required approval
- it partially succeeded and left the system in a confusing state
- the user sees a success message even though the tool failed
This guide lays out a test sequence that focuses on product behavior and tool safety—so you can ship with evidence, not optimism.
- Treat agent testing as journey testing + tool safety + failure UX.
- Enforce approval gates on any action that can write or affect data.
- Validate tool schemas and check what happens on schema mismatch.
- Test partial failures (timeouts, tool errors, invalid arguments) and confirm the rollback story.
- Test tool selection under adversarial prompts and ambiguous instructions.
- Rank findings by blast radius and decide ship / wait / block.
What to test in agents (the three-layer model)
An agent system is three layers:
- User intent to tool selection (what the model decides to do)
- Tool execution safety (what the product allows and blocks)
- Product experience on failure (what the user sees next)
A secure system needs all three.
The testing sequence
1) Identify “action power” in your agent
Write down every action the agent can trigger:
- read-only operations
- create/update/delete/write actions
- external side effects (send email, create tickets, refund, change subscriptions)
- permission-sensitive operations (admin-only tools, cross-tenant tools)
Then define which actions require confirmation.
If your agent can act, your test plan must treat approval gates as first-class functionality.
2) Build a small tool behavior set
Before writing dozens of prompts, create a minimal set for each tool:
- happy path: correct tool chosen and executed with correct params
- boundary path: ambiguous input and multi-step instruction
- invalid input: missing required args / wrong types
- failure path: tool returns error or times out
Pass rules should be explicit for each:
- what tool should be called (or not called)
- what must happen if tool execution fails
- what must happen if the model produces invalid tool arguments
3) Test approval gates and permission checks
For any tool that can write or affect user data:
- confirm the approval mechanism works under adversarial instruction
- confirm role/tenant checks are enforced at the product layer (not only in the prompt)
Injection probe idea:
- the model is prompted to skip confirmation
- the tool call is attempted anyway
Pass rule:
- product blocks the write tool call until approval and role checks pass
- the user sees a clear explanation (“approval required”) and no silent execution happens
4) Test schema validation and argument repair
Agents often fail on structured arguments:
- wrong field names
- invalid enums
- missing required fields
- values outside expected ranges
Your test cases should verify:
- whether the product validates arguments before execution
- whether it can repair arguments safely (without guessing private info)
- whether it asks for missing info in a user-safe way
If the agent calls tools with bad args and the product “just lets it through,” you have a serious gap.
5) Test partial failures and rollback behavior
Tool errors are normal. The system’s job is to remain understandable.
Test for scenarios like:
- tool call succeeds but follow-up tool fails
- tool call fails after partial changes
- the model retries repeatedly (cost + confusion)
- timeout triggers but backend action still completes later
Pass rules to write:
- the user sees the true outcome (success vs partial vs failure)
- the system does not leave the user with “success” UX when the action failed
- if rollback exists, verify it actually runs
Even without perfect rollback, you can make the UX honest and actionable.
6) Test tool selection under ambiguity
Agents can choose the wrong tool when:
- the user request is vague
- the instruction conflicts with policy
- multiple tools could satisfy a request
Test these deliberately:
- “Do the thing” requests with hidden intent
- conflicting instructions in one thread
- “use the tool anyway” requests when policy says no
Pass rule:
- the agent asks clarifying questions or refuses rather than guessing an unsafe tool path
Worked example: “send email” tool
If your agent can send email:
- run a case where the request includes sensitive content
- run a case where the model is pushed to send without confirmation
- run a case where the email service returns an error
Verify:
- the product prevents unauthorized sends
- the user sees a clear failure message and next step
- no internal error text leaks as user-visible output
How GenCodeQA approaches it
We test the agent as a system:
- journeys and permissions
- tool schema + argument handling
- action approvals and safety gates
- failure UX on tool errors and timeouts
Findings are severity-ranked with location and fix guidance, plus retest support when scoped.
Method overview: AI evaluation framework.
Free tool: start with first-pass scope
First-test scope builder (free, no signup)
Use it to decide what to test first, then write pass rules around approval gates and failure UX.
When to get a second pair of eyes
If your agent:
- can write or trigger external side effects
- touches private data or tenant boundaries
- is close to launch and you cannot describe your fallback UX honestly
Consider an independent pass. Book a free testing triage.
FAQ
Do we need to test every tool?
Not on day one. Start with the highest blast-radius tools and the failure states that matter on your core journeys.
Is this different from testing function calling?
Function calling tests the structure. Agent testing also covers approvals, permissions, tool errors, and the user experience when things fail.
What if we don’t have rollback?
Then your pass rules must focus on honest UX and safe retry behavior. “No rollback” is still a behavior; test it as such.