New Tool Radar

AI Agents & Automation

How to Test Agent Tools Against Mock Data Before They Run Live

Test agent tools against mock data before they run live, so a broken tool is found early.

Schematic with three steps: Write one mock case per tool; Call each tool directly with its mock; Fix the failures, then test the agent.

A tool that has never been called with known data is a tool you have not tested. Mock data is the test: a small set of inputs with known correct outputs, run against each tool before the agent goes live, so a broken tool, a wrong schema, or a misread result shows up in testing instead of in front of a user. LangChain’s agent harness is built from a model, a prompt, and tools, and each tool can be called on its own, outside the agent, which makes the mock test simple to run. Test every tool, not just the ones you suspect, because the tool that breaks in production is usually the one nobody tested.

What you need

  • A mock input and a known correct output for each tool
  • A way to call each tool directly, outside the agent run
  • A checklist of the tools to test, so none is skipped

Step 1: Write one mock case per tool

For each tool, write one input and the output it should return, using realistic values. A mock case with a trivial input proves little; use the shape of real data.

Step 2: Call each tool directly with its mock input

Run each tool on its own with the mock input and compare the result with the expected output. A tool that fails here will fail inside the agent too, with a harder error to read.

Step 3: Fix the failures, then test the agent end to end

Fix every tool that failed its mock case, re-run its mock case until it passes, and only then run the agent end to end. An end-to-end test on untested tools hides which tool broke.

Worked example: synthetic mock data check

The table below is a synthetic example. It shows the expected result of mock testing; no tool ran live.

Tool Mock case Result
lookup_order Order A123 Pass
search_docs Refund policy Pass
send_message Test message Fail – fixed
All tools pass before live Yes Pass

Expected result (UNTESTED). two tools pass their mock cases, the third fails and is fixed, and all tools pass before the agent goes live. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Mock data proves the tool works on the mock, not on every real input; add cases for the edge inputs.
  • A mock that is too simple passes a broken tool, so use realistic values.
  • Mock testing checks the tool, not the agent: the agent can still call it wrong.
  • Mocks go stale when the tool changes, so update them with the tool.

Sources

See all