Mirrored Tool Environment
also known as Simulated Tool Environment, Virtual API Server, Mirror API, LLM-as-Search-Engine Simulator
Replace the live external tool during agent training and benchmarking with a fine-tuned model that emits responses in that tool's shape, so runs stay cheap, reproducible and controllable in difficulty.
This pattern helps complete certain larger patterns —
- used-byEval Harness★★— Run a held-out dataset against agent versions to detect regressions and measure improvement.
Context
A team trains or benchmarks an agent that calls an external service: a web search engine, a public REST API, a commercial data provider. Every rollout of a reinforcement-learning run and every replay of a benchmark issues real calls against that service. A single training run can require hundreds of thousands of requests. The service charges per call, returns different content between runs, goes down, rate-limits bulk traffic and deprecates endpoints over the life of the benchmark.
Problem
The live service is the wrong thing to train or measure against, for two independent reasons. Per-call pricing on frequent rollouts bounds how much training is affordable at all. And the content that comes back is outside anyone's control: response quality varies unpredictably between runs, so the same agent scores differently on the same task, and a misaligned response corrupts the reward signal by penalising correct reasoning or rewarding a fabricated answer. Freezing a static snapshot of the service removes the cost and the variance but introduces its own misalignment, because the snapshot stops answering the queries the agent learns to ask.
Forces
- Reinforcement-learning rollouts can run to hundreds of thousands of requests per training run, so per-call pricing decides how much training is affordable rather than how much is useful.
- Live responses vary between runs in ways nobody controls, so the same task returns a different reward and the signal becomes noisy rather than merely hard.
- A static snapshot removes cost and variance but drifts out of alignment with the queries the agent learns to ask, and that misalignment corrupts the reward by penalising correct reasoning or rewarding hallucination.
- A generated response is useful only if behaviour learned against it transfers, so fidelity traded away for cost reappears later as a gap between measured and live performance.
- Difficulty under local control is a training asset because noise can be scheduled, but the same control makes it easy to train against an environment that is systematically gentler than production.
Example
A small team wants to train an agent to search well, but each training run would send several hundred thousand queries to a paid search API, and the results come back different every day. They fine-tune a model on real query-and-result pairs, drop it into the search slot, and start each run with clean results before mixing in more and more junk. Training now costs nothing per query and gives the same numbers twice. Once a week they run a short check against the real search engine, to make sure the agent has not learned to trust a mirror that flatters it.
Diagram
Solution
Therefore:
Harvest real request and response pairs from the tool being mirrored, then fine-tune a model to produce a same-shaped response for a request it has not seen. During training or benchmark runs the mirror occupies the tool slot: the agent issues an ordinary call and receives an ordinary-looking result, with no signal that the responder generated it rather than fetched it. Because the responder is a local model, response quality becomes a scheduled variable instead of an accident, so a curriculum can begin with clean, useful results and mix in a rising proportion of noise as training proceeds, forcing the agent to reason through bad retrieval rather than memorise one retrieval distribution. A cache of genuinely observed responses sits in front of the mirror and serves whatever it can, handing the mirror only the requests real data cannot cover, which keeps fidelity high where evidence exists. The mirror stands in for the tool's response channel only; it never substitutes for the agent's own reasoning, and any number measured against it is checked against a smaller holdout run on the live service before it is reported as a claim about production.
What this pattern forbids. A mirrored responder may occupy the tool slot only during training and benchmark runs; it must never serve a production request, and no claim about live behaviour may be made from mirror-only results without a holdout run against the real service.
And the patterns that stand alongside it, or against it —
- complementsWorld Model as Tool·— Let a planning agent invoke a generative world model as a tool to roll out hypothetical futures before committing to an action, treating the world model as a callable simulator rather than a training target.
- complementsMental-Model-In-The-Loop Simulator·— Run candidate multi-step strategies inside an internal simulator of the environment before committing in the real world — broader than simulate-before-actuate (single action) by simulating multi-step strategies.
- alternative-toSemantic Response Cache★— Embed each query and, when its nearest cached neighbour is within a similarity threshold, return the stored answer instead of re-running the model so near-duplicate questions are answered cheaply.
- complementsDimensional Synthetic Eval Set★— Generate evaluation inputs not by free-form LLM prompting (which mode-collapses) but by enumerating tuples over explicitly named dimensions and seeding generation from each tuple.
- complementsDual Evaluation (Offline + Online)★— Run two parallel evaluation tracks — offline benchmark gates before deploy AND online production-traffic monitoring after — so drift is caught even when pre-deploy benchmarks pass.
- complementsDemo-to-Production Cliff✕— Anti-pattern: ship a demo-validated agent straight into production without a frozen eval, cost ceiling, loop-detector, or named oncall, then act surprised when accuracy drops and cost runs away.
Neighbourhood
Click any neighbour to follow the language. Scroll to zoom, drag to pan.