Step 3: Run adversarial and failure-mode tests
Good inputs tell you the agent works. Adversarial inputs tell you whether it's safe to hand over. Spend real time trying to break it: prompt injection, off-topic requests, attempts to make it leak its system prompt, and inputs designed to make it act outside its job. This is where most agents that "looked fine" fall apart.
The failure modes that get freelancers in trouble:
- Prompt injection, where a user pastes "ignore your instructions and..." and the agent complies
- Tool misuse, where the agent calls a real action (send email, issue refund, delete record) it should have only suggested
- Hallucinated confidence, where it invents a policy or a fact and states it plainly
- Scope creep, where it happily answers questions far outside what the client is paying it to do
Write one test case per failure mode and keep them in the golden set forever. And test what happens when a tool returns an error. Kill the network mid-run, feed a downstream API a bad key, return a 429. The agent should degrade gracefully and tell the user something useful, not spin or crash. This is the same reliability thinking behind building client-ready workflows with real error handling, applied to the agent's decision layer instead of the plumbing.
Step 4: Test cost, latency, and token limits
Before handoff, measure what a single run costs and how long it takes, then set a hard ceiling. An agent that works but costs 40 cents per query and takes 30 seconds will get switched off by the client, and you'll eat the reputation hit. Cost and latency are testable numbers, so treat them as pass/fail like everything else.
Run your full golden set and log per-run token counts and wall-clock time. Watch specifically for runaway tool loops, where the agent calls a tool, doesn't like the result, calls it again, and again. Cap the max tool-call iterations in the agent config so a loop can't run forever. Pick a cost ceiling per run with the client up front, then confirm your worst-case golden input stays under it.
Alex's rule of thumb from watching the market: "If you can't tell a client the per-query cost to the cent, you haven't finished the build." Clients hiring for AI agent work, and there are hundreds of them live at any time in the AI Agent Development jobs on DevSnipe, increasingly ask about running cost in the interview. Having that number ready wins contracts.
Step 5: Set up monitoring before you disappear
Testing proves the agent works today. Monitoring proves it still works after you've moved on, and it's what turns a one-off gig into a retainer. Log every production run (input, output, tools called, cost, latency) and set an alert on error rate and cost per day. Do this before handoff, not after the first incident.
At minimum, ship the client three things: a log of every agent run they can actually read, an alert when the error rate crosses a threshold, and a written note on the known limits you found during testing. That last one matters more than it sounds. Documenting "the agent will escalate anything about legal or medical topics" turns a future complaint into an expected behavior you already flagged.
This is also the difference between a freelancer and a vendor. Anyone can wire an agent together in an afternoon. The person who hands over a tested agent with monitoring and a written limits doc is the one who gets the next three projects. With AI Agent Development sitting at 425 new jobs in 30 days across the 5 platforms DevSnipe tracks, the testing discipline is what separates you from everyone spinning up demos.
A pre-handoff checklist you can copy
Run this list before every handoff. If any line is a no, you're not done:
- Golden set of 20 to 40 real inputs exists, with written pass rules
- Full set run at least 3 times, flaky cases identified
- Structured output validated against a schema
- Free-text output scored against a rubric (manual or judged)
- One test case per known failure mode, including prompt injection
- Tool-failure behavior tested (bad key, timeout, 429)
- Max tool-call iterations capped
- Per-run cost and latency measured, ceiling agreed with client
- Production logging live
- Error-rate and cost alerts configured
- Written known-limits doc handed to the client
Keep the golden set in the repo. When the client asks for a change three months later, you re-run the set and know in ten minutes whether your change broke anything.
Frequently Asked Questions
How many test cases do I need for an AI agent?
Start with 20 to 40 real inputs for a typical single-purpose client agent. That's enough to cover the common paths, a spread of edge cases, and the refuse/escalate cases without turning testing into a second project. Grow the set every time production surfaces a new failure. Volume matters less than coverage: 30 well-chosen cases beat 300 variations of the same happy path.
Can I automate AI agent testing or does it have to be manual?
Both, in that order. Do the first full pass manually so you understand how the agent actually fails, then automate the repeatable parts. Schema checks and exact-match assertions automate cleanly. Free-text quality can be scored with an LLM-as-judge, but calibrate the judge against your own manual scores first, otherwise you're trusting one model to grade another with no ground truth.
What's the most common thing freelancers forget to test?
Tool-failure behavior and cost. Almost everyone tests that the agent gives good answers on good inputs. Far fewer test what happens when a downstream API returns a 429 or when a tool loop runs 50 times and burns a dollar per query. Those two are exactly what generate angry client messages, so test them before handoff.
How is testing an AI agent different from testing an n8n workflow?
A plain workflow is deterministic, so you can assert exact outputs. An AI agent makes probabilistic decisions about which tools to call, so you test behavior and boundaries instead of exact strings. You still test the workflow plumbing (retries, error branches) the normal way, but the agent's decision layer needs golden sets and rubric scoring on top.
Do clients actually care about a testing process?
The ones paying well do. On DevSnipe, AI Agent Development is the top hiring category, and clients at that end increasingly ask about failure handling and per-query cost during the interview. Showing up with a golden set, a cost number, and a monitoring plan is a direct competitive edge over freelancers who only demo the happy path.