
After studying this material, you should be able to:
Imagine running a customer support system handling 100,000 AI tickets per day.
1% error rate = 1,000 bad customer experiences DAILY
Traditional software thinking says:
"If the server is up and returning responses, everything is fine."
This is completely wrong for AI agents.
An agent can have:
Unlike simple software, an AI agent is a multi-step workflow:
Customer Query
↓
[Classify Intent]
↓
[Retrieve Knowledge]
↓
[Analyze Inputs]
↓
[Reason Through Decision]
↓
[Call Tools/APIs]
↓
[Generate Response]
Failure can happen at ANY step, not just the final answer.
This is called the Assurance Gap — the space between "the system is running" and "the system is working correctly."
| Pressure | Example |
|---|---|
| Volume spikes | Diwali, weather events |
| Category expansion | Adding electronics, apparel to groceries |
| Diverse users | Multilingual customers, new request types |
| New failure modes | Fraud patterns, edge cases |
Key Insight: "Just ship the agent" works until it breaks at scale. Evaluation must be infrastructure, not an afterthought.
This is the central concept of the entire framework.
┌─────────────────────────────────────────────────────┐
│ DEVELOPMENT LOOP │
│ │
│ Code Change → Golden Dataset Test → Scorers → │
│ Quality Gate → Auto-Deploy (if passed) │
└──────────────────────┬──────────────────────────────┘
│ Quality Gate
↓
[PRODUCTION ENVIRONMENT]
│
↓
┌─────────────────────────────────────────────────────┐
│ PRODUCTION LOOP │
│ │
│ Live Traffic → Traces → Online Evaluation → │
│ Alerts → Failure Captured → Fed Back to Dev Loop │
└─────────────────────────────────────────────────────┘
Development Loop asks: "Is this agent ready for production?"
Production Loop asks: "Is the live agent still working correctly?"
Key Insight: Every production failure becomes a test case. The system gets smarter over time automatically.
What it is: Recording every step of every agent interaction
What gets captured:
How it works technically:
# One line enables automatic tracing
mlflow.<library>.autolog()
# Custom spans for specific steps
@mlflow.trace
def my_custom_step():
# your code here
Why it matters: Without traces, you only see input and output. With traces, you see everything in between — where failures actually occur.
What it is: Translating stakeholder needs into measurable thresholds
Instead of vague debates about quality, each stakeholder defines what success means numerically:
┌─────────────────────────────────────────────────────┐
│ EVALUATION PILLARS │
├──────────────────┬──────────────────────────────────┤
│ Customer │ Response accuracy > 94% │
│ Experience │ Empathy score > threshold │
│ │ Resolution rate > X% │
├──────────────────┼──────────────────────────────────┤
│ Operational │ Automation rate > 80% │
│ Efficiency │ Escalation rate < Y% │
│ │ Latency P95 < Z ms │
├──────────────────┼──────────────────────────────────┤
│ Risk & │ Fraud detection rate > threshold │
│ Compliance │ Zero prompt injection pass-through│
├──────────────────┼──────────────────────────────────┤
│ Financial │ Cost per ticket < $X │
│ Impact │ Refund accuracy within policy │
└──────────────────┴──────────────────────────────────┘
Key principle: All gates must pass before deployment. This turns subjective quality debates into objective, shared contracts.
What it is: A curated collection of test examples that represents the full range of real-world scenarios
Requirements for a good golden dataset:
How it evolves over time (Zepto's journey):
Month 1: 500 examples → 8-point dev/prod accuracy gap
Month 3: 2,000 examples → 2-point gap
Month 6: 5,247 examples → 0.4-point gap
The 10x Rule:
Every hour spent improving the golden dataset saves ~10 hours of production debugging.
Why the gap matters: If your agent scores 94% on development tests but only 86% in production, your dataset is missing 8 points worth of real-world scenarios.
What it is: Automated systems that evaluate agent outputs along multiple dimensions
Three types of scorers:
┌─────────────────────────────────────────────────────┐
│ AI JURY │
├──────────────────┬──────────────────────────────────┤
│ Rule-Based │ Use when: deterministic logic │
│ Scorers │ Example: Did agent call the │
│ │ correct API? (yes/no) │
├──────────────────┼──────────────────────────────────┤
│ ML Model │ Use when: pattern recognition │
│ Scorers │ Example: Sentiment classification │
├──────────────────┼──────────────────────────────────┤
│ LLM-Based │ Use when: human-like judgment │
│ Scorers │ Example: Was the response │
│ │ empathetic? Was it grounded? │
└──────────────────┴──────────────────────────────────┘
Best practices:
The problem: Evaluating 100% of traffic is too expensive. But random 10% sampling misses most edge cases.
The solution: Sample strategically based on risk:
HIGH sampling rate for:
├── High-value customers
├── New or recently changed features
├── Negative sentiment detected
├── High escalation risk signals
└── Image-based or fraud-prone interactions
LOWER sampling rate for:
└── Routine, low-risk interactions
Results of this approach:
| Metric | Uniform Sampling | Stratified Sampling |
|---|---|---|
| Sample rate | 10% | 18-20% |
| Daily traces reviewed | ~10,000 | ~14,400 |
| Edge cases captured | Low | 45-60% |
| Issue detection time | Slow | 4-6 minutes |
| Cost per issue found | Baseline | 86% reduction |
| Edge case detection | Baseline | 9x improvement |
A well-designed agent architecture makes evaluation easier by being decomposable — you can measure each piece separately.
Customer Query
↓
[Orchestrator / Router]
↓
┌────────────────┴────────────────┐
↓ ↓
VERTICAL AGENTS HORIZONTAL AGENTS
(Specialists) (Oversight Layers)
• WIMO Agent • Fraud Detection Agent
(Where Is My Order) • Image Validation Agent
• Refund Agent • Quality Assessment Agent
• Cancellation Agent • Compliance Agent
• Expiry/Quality Agent
Vertical agents = Deep expertise in one domain
Horizontal agents = Cross-cutting concerns applied to all interactions
Why this separation matters for evaluation:
Engineer makes a change
↓
Automated regression triggered
↓
Change tested against Golden Dataset
↓
Scorers evaluate across all pillars
↓
┌────┴────┐
↓ ↓
All gates Any gate
passed? failed?
↓ ↓
Auto-deploy Block + Alert
to production engineer
Instead of manually writing and testing prompts:
1. Register initial prompt in MLflow
↓
2. Generate multiple prompt variants automatically
↓
3. Score all variants against golden dataset
(using same scorers that gate deployment)
↓
4. A/B evaluate automatically
↓
5. Deploy best-performing variant
Cost-aware optimization trick: Use a powerful (expensive) model to generate candidate prompts, but use a cheaper model to score them. This keeps the search process affordable.
CRITICAL (checked every 5 minutes):
├── Intent accuracy drops below threshold
├── Groundedness violations detected
├── High escalation risk spike
└── P95 latency breach
HIGH/MEDIUM (monitored continuously):
├── Empathy score degradation
├── Cost per ticket spike
├── Tool failure rate increase
├── CSAT trend decline
├── Fraud detection rate change
└── Multimodal processing latency
What happened:
How evaluation caught it:
What changed as a result:
Old behavior: Repeat cached ETA indefinitely
New rule: If rider stationary > 10 minutes:
├── Give honest status update
└── Proactively offer cancellation + full refund
New features unlocked by this insight:
When customers submit photos of damaged/expired products, evaluation becomes complex:
Challenge 1: Human disagreement
Challenge 2: AI plays it safe
Challenge 3: Edge cases
For refund abuse (fake photos, edited images, reused images):
Image submitted
↓
Preprocessing checks
(blur, brightness, resolution)
↓
OCR validation
↓
Jury of 3 vision models
(consensus rules)
↓
Additional checks:
├── Blur detection
├── Screenshot detection
├── Duplicate image detection
├── Image vs. SKU matching
├── Image vs. stated reason check
└── Proof-of-delivery validation
↓
Auto-approve OR Route to human review
| Category | Result |
|---|---|
| Tickets handled by AI | 80%+ |
| Support cost reduction | 65% |
| Payback period | Under 1 month |
| Dev/prod accuracy gap | Reduced from 8 points to 0.4 points |
| Edge case detection improvement | 9x |
| Review cost reduction per issue | 86% |
Evaluation is infrastructure, not a final check
Traces are your foundation
Golden datasets compound in value
Use the right scorer for the right job
Sample strategically, not uniformly
Architecture and evaluation co-design
The dual loop creates a self-improving system
EVALUATION-FIRST AI AGENTS
│
├── WHY: Assurance gap between "running" and "working correctly"
│
├── WHAT: Dual-loop model
│ ├── Development Loop: Test before production
│ └── Production Loop: Monitor in production
│
├── HOW: Five building blocks
│ ├── 1. Tracing (observe everything)
│ ├── 2. Evaluation Pillars (measure what matters)
│ ├── 3. Golden Dataset (source of truth)
│ ├── 4. Scorers/AI Jury (automated evaluation)
│ └── 5. Stratified Sampling (efficient coverage)
│
├── ARCHITECTURE: Vertical + Horizontal agents
│ ├── Vertical: Domain specialists (measurable in isolation)
│ └── Horizontal: Cross-cutting oversight layers
│
└── RESULTS: 80%+ automation, 65% cost reduction, <1 month payback