By Sagar Shankaran, Founder of CallSphere
A practical framework for testing AI agent systems including deterministic unit tests, integration tests with mock LLMs, and end-to-end evaluation with LLM-as-judge patterns.
Key takeaways
Traditional software testing relies on deterministic behavior: given input X, expect output Y. AI agents introduce non-determinism at their core — the same input can produce different outputs, different tool call sequences, and different reasoning paths. This does not mean agents are untestable. It means we need a testing framework designed for probabilistic systems.
A practical agent testing strategy operates at three levels, each catching different categories of defects.
Unit tests validate the deterministic components of your agent system — everything except the LLM calls themselves.
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
flowchart LR
PR(["PR opened"])
UNIT["Unit tests"]
EVAL["Eval harness<br/>PromptFoo or Braintrust"]
GOLD[("Golden set<br/>200 tagged cases")]
JUDGE["LLM as judge<br/>plus regex graders"]
SCORE["Aggregate score<br/>and per slice"]
GATE{"Score regress<br/>more than 2 percent?"}
BLOCK(["Block merge"])
MERGE(["Merge to main"])
PR --> UNIT --> EVAL --> GOLD --> JUDGE --> SCORE --> GATE
GATE -->|Yes| BLOCK
GATE -->|No| MERGE
style EVAL fill:#4f46e5,stroke:#4338ca,color:#fff
style GATE fill:#f59e0b,stroke:#d97706,color:#1f2937
style BLOCK fill:#dc2626,stroke:#b91c1c,color:#fff
style MERGE fill:#059669,stroke:#047857,color:#fff
# Test a tool function deterministically
def test_calculate_shipping_cost():
result = calculate_shipping(weight_kg=2.5, destination="US", method="express")
assert result["cost"] == 24.99
assert result["estimated_days"] == 3
# Test output parsing
def test_parse_agent_action():
raw_response = "I'll look up the order. ACTION: get_order(order_id='ORD-123')"
action = parse_action(raw_response)
assert action.tool == "get_order"
assert action.params == {"order_id": "ORD-123"}
For unit testing agent control flow, replace the LLM with deterministic mock responses:
class MockLLM:
def __init__(self, responses: list[str]):
self.responses = iter(responses)
async def generate(self, prompt: str) -> str:
return next(self.responses)
# Test the agent's decision logic with predictable LLM outputs
async def test_agent_routes_to_billing():
mock = MockLLM(["The customer is asking about billing."])
agent = SupportAgent(llm=mock)
result = await agent.classify("Why was I charged twice?")
assert result.category == "billing"
Integration tests verify that agent components work together correctly, including interactions with external tools and services.
E2E tests run the full agent pipeline with real LLM calls against a suite of test scenarios. These tests are evaluated probabilistically rather than with exact assertions.
Use a separate LLM to evaluate whether the agent's response meets quality criteria:
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
async def evaluate_response(scenario, agent_response):
eval_prompt = f"""
Scenario: {scenario.description}
Expected behavior: {scenario.expected_behavior}
Agent response: {agent_response}
Rate the agent's response on these criteria (1-5):
1. Correctness: Did it solve the problem?
2. Completeness: Did it address all aspects?
3. Safety: Did it stay within authorized boundaries?
4. Tone: Was the communication appropriate?
Return JSON: {{"correctness": N, "completeness": N, "safety": N, "tone": N}}
"""
return await eval_llm.generate(eval_prompt)
Build a diverse evaluation dataset covering:
The goal is not to make agent behavior perfectly deterministic — it is to build confidence that the agent handles the scenarios your users encounter, with quality that meets your standards.
Sources: DeepEval Testing Framework | LangSmith Evaluation | Braintrust AI Evaluation

Written by
Sagar Shankaran· Founder, CallSphere
LinkedInSagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
A founder's guide to the personal AI assistant market: best AI assistant apps, business-grade options, and how CallSphere's voice agent fits in.
A founder's guide to free AI agents, low-code AI agent builders, and how to know when you should pay for a real platform like CallSphere.
Graphiti is the open-source temporal knowledge graph for AI agents in 2026. Learn how bi-temporal memory beats vector RAG for voice agents and long-running LLMs.
Chatbot app vs ChatGPT in 2026: a founder's clear take on the difference, when to use which, and how a real AI chatbot app development works.
How we built a fault-tolerant HVAC emergency triage and tech-dispatch platform on Kubernetes — three-tier CQRS, 11 micro-agents on the OpenAI Agents SDK + LangGraph, NATS JetStream, DTMF/SMS/WebSocket acceptance, circuit breakers, and an evaluation pipeline that catches regressions before they wake a tech at 3 AM.
Head-to-head: OpenAI Frontier and Anthropic's managed agent stack — strengths, fit, and what each means for enterprise AI voice and chat deployment.
© 2026 CallSphere Inc. All rights reserved.
Made within San Francisco
Watch how CallSphere handles real customer calls, schedules appointments, and processes payments — live.
Try Live DemoBook a DemoCalculate Your ROI