I’ve been exploring ways to improve the reliability of AI agents built with LangChain and LangGraph, particularly before deploying them into production environments.
Traditional software testing approaches don’t always cover the unpredictable behavior of LLM-powered applications.
I’m interested in understanding how other developers approach this.
A few questions:
How do you test agent decisions across different inputs and execution paths?
Do you maintain evaluation datasets for measuring response accuracy?
How do you handle hallucinations and inconsistent agent responses?
What tools do you use for tracing, debugging, and monitoring agent execution?
How frequently do you run evaluations when changing prompts or models?
I’d appreciate practical recommendations and examples from developers working with production AI agents.
Hi Ryan, great question! Here’s the setup we usually recommend, going through your questions in order.
1. Testing decisions across inputs and execution paths
Think about it in layers:
Unit tests for deterministic logic. LangGraph lets you test individual nodes and edges, and run part of a graph from a specific checkpoint, so you can check routing logic without running the whole agent: Test - Docs by LangChain
Yes, definitely. Start small (20 to 50 hand-picked examples covering your core flows and known edge cases) and keep growing it from production traces, especially failures. You can add traces to a dataset straight from the UI, and annotation queues help with getting human labels on them:
For #5, my answer is on every change, and that only works if a rerun is cheap. What we do is keep the eval set in a table: inputs, expected output, the agent’s answer and an LLM-judge score as columns. Change the prompt or the model and only the answer and score columns recompute. The inputs stay put, so you can compare scores between the two runs before shipping. A judge column that checks the answer against the retrieved context is a decent first pass on hallucinations, just spot-check the judge by hand too. Cookbook for the judge part: docs.pixeltable.com/howto/cookbooks/agents/pattern-llm-judge
Great question, Ryan. jimguan052’s answer covers the eval side really well, so I’ll add the part that tends to bite after launch: most of our production incidents didn’t come from the model making a bad decision, they came from something around the model failing.
Test with broken tools, not just good inputs: Mock each tool to time out, return an error, return an empty result, and return malformed data, then check what the agent does. The failure modes you’re looking for are retry loops that never end, the agent quietly skipping a step, or it confidently answering anyway. A handful of these fault-injection cases in your dataset catches a surprising amount.
Run cheap checks before LLM judges: Validate output schemas and tool-call arguments with plain code first. It’s instant, free, and fully deterministic, so the LLM-as-judge only has to score what code genuinely can’t check. That also keeps the “eval on every change” approach pierrebrunelle described affordable.
Treat empty results as a hallucination risk: Something I’ve seen come up again and again on agent work at Technource is that a lot of “hallucination” is really retrieval or a tool returning nothing, and the model filling the gap. Give the agent an explicit “I couldn’t find that” path, and add test cases where the right answer is exactly that.