Zero Labs
Industry News / AI

HTTP 200 OK, Yet Completely Wrong: How We Built an Observability Engine for AI Agents

Source · Towards AI By Ujjwaldash

From the publisher’s feed, collected in the ZeroLabs newsroom.

Traditional monitoring tells you if your agent is alive, not if it’s right. Here is the asynchronous architecture we built to evaluate thousands of production chats overnight.Arnav had just shipped his company’s first production AI assistant. Before launch, he tested it on a carefully curated set of 200 questions. It scored 92%. Everything looked green, response times were fast, and there were zero error logs.Two weeks later, a major client sent an urgent message: “Your AI has been giving us wrong policy answers since last week.”Arnav stared at his monitoring dashboard. Every single API call showed 200 OK. His system was alive, fast, and completely confident—while quietly hallucinating. That afternoon, Arnav realized that traditional server monitoring only tells you if your AI is running, never if it is right.The Trap of the Static Test FileAt first, Arnav relied on his 200-question test dataset whenever he changed a prompt. That failed almost immediately. Real users didn’t talk like his neat test file — they asked messy follow-up questions, combined two requests into one, and triggered edge cases his static dataset never imagined.[Static 200-Question File] ──► [Manual Eval Script] ──► Score: 92% (Blind to real users)So Arnav abandoned offline-only testing and decided to pull real production conversations directly from cloud storage (S3) on a daily schedule.To avoid adding latency to live user chats, he moved evaluation completely out of the request path into an asynchronous overnight pipeline. A daily scheduler (APScheduler) woke up once a day and sampled a manageable slice of yesterday’s chats from S3.[Live User] ──► [AI Agent] ──► Fast Reply (No eval delay!) │ ▼ [Raw Chat Logs (S3)] │ (Daily Scheduler + Sampler) │ ▼ [Background Grader]The very first night the scheduled job ran, it crashed halfway through. One of the teams had updated their agent and accidentally changed a field name in their chat logs, breaking Arnav’s script.To stop a single malformed log file from taking down an entire night’s batch, Arnav added a strict YAML schema validator right after ingestion. Only conversations matching the standardized format — containing a conversation_id, tenant_id, user turns, assistant replies, and any retrieved RAG documents or tool calls—were copied into a validated evaluation bucket. Rather than throwing all those chats at the grader simultaneously (causing memory spikes and API rate limits), he dropped lightweight job tickets into an Amazon SQS queue so a sequential background worker could pull and grade them safely one by one.[Raw Chat Logs (S3)] │ ▼ [YAML Schema Validator] ──► (Rejects broken logs safely) │ ▼[Validated Eval Bucket (S3)] ──► [Amazon SQS Queue] ──► [Sequential Worker]Insight 1: Why an LLM Judge Confidently Lies (and Why a 0.98 Faithfulness Score Can Still Mean a Broken Agent)Once the pipeline stopped crashing, Arnav ran into a much subtler problem: he couldn’t trust the scores.Initially, he sent each conversation to an LLM judge with a simple prompt: “Rate this response from 0 to 1.” Running the exact same conversation three times produced 0.78, 0.69, and 0.84. Worse, metric bleed crept in—if the agent used a slightly blunt tone, the judge quietly docked points from its Relevance score, blending unrelated flaws into a single blurry number. Meanwhile, paying an expensive frontier LLM just to verify basic math—like whether the search engine fetched the right document—was burning budget unnecessarily.Arnav replaced his single vague prompt with a three-tier Evaluation Orchestrator:Computational Metrics: Pure, free math (Precision@k and Recall@k) whenever ground-truth retrieval checks were possible.Embedding Metrics: Fast vector-similarity checks for semantic closeness.LLM-as-a-Judge via DeepEval (GEval): Isolated, step-by-step rubrics using token probabilities where each metric ran independently—so tone never polluted Relevance, and every grade required a written explanation.[Amazon SQS Queue] │ ▼[Sequential Worker] │ ▼[Evaluation Orchestrator] ├──► Computational Metrics (Precision@k, Recall@k — Fast & Free) ├──► Embedding Metrics (Semantic similarity) └──► LLM Judge via DeepEval GEval (Isolated rubrics + written reasons) │ ▼[Results Bucket (S3)]Yet even with isolated metrics, Arnav noticed something bizarre a few weeks later: an agent’s Faithfulness score climbed to 0.98, while users were furiously clicking thumbs-down.When Arnav inspected the turn logs, the realization hit him: a higher Faithfulness score does not mean a better agent. Faithfulness only measures whether the AI stuck to the retrieved documents without inventing facts. When the search engine retrieved an outdated or irrelevant policy document — and the agent faithfully summarized that wrong document — the judge awarded a near-perfect 0.98 for Faithfulness while the user got a useless answer.That taught Arnav never to trust a single metric in isolation — Faithfulness had to be paired with Contextual Precision and Goal Accuracy to tell the true story.Insight 2: Why Evaluating 100% of Conversations Is Worse Than Smart SamplingAs daily traffic grew into the tens of thousands of chats, a stakeholder asked: “Shouldn’t we evaluate every single conversation so nothing slips through?”Arnav ran the math and realized exhaustive evaluation wasn’t just expensive — it was actively counterproductive. Grading 100% of traffic with multi-metric LLM judges would burn through their monthly inference budget in four days, forcing the team to downgrade to a weaker, cheaper judge model that missed subtle multi-turn reasoning errors. Furthermore, because 70% of production traffic consisted of repetitive greetings and routine FAQ lookups, grading every chat drowned out rare, complex edge cases in a sea of trivial 1.0 scores.To control both quality and scale, Arnav made the entire pipeline config-driven. Teams registered their agents in a central configuration store (configGroup: schedular-agents) specifying their agent’s name, S3 log location, sample percentage, judge model, and which of the 27 available metrics to track—without touching a single line of pipeline code. Evaluating a curated, representative daily sample using a strong frontier judge model under consistent rubrics gave far sharper signal than running a weak judge over every chat.Insight 3: How a Healthy 0.85 Average Hid a Failing ClientAfter running this orchestrator at scale, Arnav had a new headache: 10,000 raw JSON result files sitting in S3. Looking at thousands of text files — or a single company-wide average score — hid critical failures. When an agent’s overall weekly Goal Accuracy dipped slightly from 0.85 to 0.82, it looked like harmless noise.So Arnav built a background sync service (backed by PostgreSQL) that read the daily S3 results and manifest files and organized them cleanly inside MLflow:Workspaces: Separate workspaces for DEV, QA, and PROD so test runs never mixed with live traffic.Experiments: One dedicated experiment per AI agent.Runs: One run per conversation, tagged with conversation_id, tenant_id, judge_model, metric scores, and the judge’s written reasoning.Artifacts: Interactive Plotly HTML dashboards — weekly trend lines with smoothing sliders, tenant comparisons, token-cost charts, and conversation-by-metric heatmaps — attached directly inside MLflow.Five-Minute Debugging in ProductionTwo months later, when Arnav opened the PROD workspace in MLflow and sliced a minor 0.82 Goal Accuracy dip by client, the company-wide average turned out to be hiding a localized outage: nine enterprise clients were sitting comfortably at 0.88, while Client B had plunged to 0.54.Arnav clicked into Client B’s monthly heatmap. Faithfulness was bright green (0.95), proving the LLM wasn’t hallucinating. Retrieval Precision, however, was solid red. He opened the lowest-scoring conversation run and read the judge’s exact note:“The retrieved context did not contain the client’s updated policy table.”In under five minutes — without grepping raw logs or blaming the LLM — Arnav knew Client B’s search index simply needed a refresh.With the pipeline now running quietly on autopilot every night, Arnav is adding one final piece to the story: automated A/B testing, so whenever his team wants to test a new prompt or switch to a new model, they can run both versions side by side on the exact same real conversations and let the numbers decide which one ships.References1. LLM-as-a-Judge & Structured Rubrics (GEval)G-Eval: NLG Evaluation using GPT-4 with Better Human Alignment — Liu et al. (2023). The foundational paper introducing chain-of-thought evaluation criteria and token log-probability weighted scoring to reduce LLM judge variance.arXiv: [https://arxiv.org/abs/2303.16634]DeepEval Documentation — G-Eval & Custom Metrics — Official guide on building isolated, criteria-driven LLM evaluation metrics and extending custom evaluation classes.Docs: [https://docs.confident-ai.com/docs/metrics-llm-evals]2. RAG Evaluation & Retrieval vs. Generation MetricsRAGAS: Automated Evaluation of Retrieval Augmented Generation — Es et al. (2023). Defines the distinction between retrieval quality (Context Precision/Recall) and generation loyalty (Faithfulness and Answer Relevancy), explaining why high faithfulness can coexist with poor retrieval.arXiv: [https://arxiv.org/abs/2309.15217]3. Experiment Tracking, Observability & Scheduling InfrastructureMLflow Tracking & GenAI Evaluation Documentation — Official documentation on structuring workspaces/experiments, logging per-run parameters/metrics, and attaching custom HTML/Plotly artifacts.Docs: [https://mlflow.org/docs/latest/tracking.html]HTTP 200 OK, Yet Completely Wrong: How We Built an Observability Engine for AI Agents was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.