inferwire
/
AI·4 min read

LLM Agents Lose Accuracy Searching Their Own Tool Outputs

Storing large tool outputs in external files and making LLM agents search them degrades task accuracy, even when the underlying tools produce fully deterministic data.

TL;DR

  • Modern AI agent harnesses keep long tool outputs in files and force models to search them, causing substantial accuracy loss [^1].
  • Testing with USGS geochemical simulations revealed that retrieval steps introduce extraction errors even when computational output is perfectly deterministic [^1] [^2].

Background

Large language models increasingly execute external tools, software applications, and code scripts to solve domain-specific tasks. When tools generate massive reports containing tens of thousands of lines, harness developers cannot fit the entire output directly into a context window without exceeding token limits or incurring high financial costs. To solve this constraint, agent frameworks write tool responses to disk and instruct the model to inspect or grep those files iteratively. While this architecture controls token consumption, it shifts the system's reliance from direct computational reading to multi-step retrieval operations.

What happened

Researchers evaluated how external file retention impacts the accuracy of language model agents executing complex scientific simulations [^1]. The research team tested agent frameworks against PHREEQC, a deterministic geochemical simulation program maintained by the United States Geological Survey (USGS) [^2]. PHREEQC calculates chemical reactions, fluid transport, and equilibrium models across hydrogeology projects, frequently producing text reports that exceed 800,000 characters [^1] [^2].

Because PHREEQC is fully deterministic, running identical input parameters always produces identical numerical output [^2]. This physical consistency allowed the researchers to isolate precisely where AI agents failed during multi-turn problem-solving runs [^1]. The study compared two main operational modes: standard full-context execution, where the model sees the complete output text, and harness-driven file retrieval, where the agent uses line-reading or search commands to extract relevant slices of output stored on disk [^1].

The findings demonstrated a pronounced drop in final task accuracy when agents relied on file retrieval tools to inspect simulation outputs [^1]. Even though the underlying simulator computed correct values every time, the agents frequently failed to retrieve the precise data fields needed to complete downstream calculation tasks [^1]. The failure modes fell primarily into three categories: incomplete search parameters, partial line extraction, and misinterpreting tabular headers when viewing isolated fragments of text out of context [^1].

Furthermore, the researchers discovered that iterative retrieval introduced compounding error loops [^1]. When an agent issued a sub-optimal search query to read a log file, the incomplete result corrupted its internal plan. Rather than refining its search parameters, the agent often treated the partial output as absolute truth, leading to incorrect calculations despite having generated the exact ground-truth simulation file seconds earlier [^1].

Why it matters

As software developers deploy autonomous agents for enterprise automation, offloading large payloads to external storage has become standard architectural practice. Frameworks frequently implement file-system tools or local search indexes to keep prompt token counts low. However, this study proves that saving context window space comes with a hidden accuracy tax. When software architectures replace direct model perception with intermediate retrieval steps, the retrieval mechanism itself becomes a primary point of system failure.

The core issue lies in the fundamental difference between data processing and data retrieval. While foundational language models exhibit strong reasoning capabilities over text present directly within their prompt context, their ability to construct surgical search queries across raw text files remains imperfect. When an output file spans thousands of structured data rows, a minor syntax error in a file-search command causes the model to miss critical data points. The agent then proceeds through its reasoning chain with corrupted context, failing to realize that its information gap stems from a flawed search query rather than a flawed calculation.

This reality presents a critical trade-off for engineers building AI agent workflows. Simply increasing context lengths or lowering execution costs by offloading raw tool outputs to vector stores or file systems does not guarantee reliable performance. For high-stakes domains like engineering, financial auditing, and scientific simulation, software teams must design structured output parsers rather than relying on LLMs to grep raw log files. Converting bulk outputs into structured JSON summaries or specialized database schemas before handing them to an agent yields far higher reliability than expecting the agent to query raw files autonomously.

Practical example

Suppose an environmental consultant uses an AI agent to run water quality simulations across twenty municipal wells. The agent calls the USGS PHREEQC tool, which generates an 800,000-character chemical breakdown file for each well. To save money on API tokens, the agent harness saves these files to a local folder and gives the agent a file-search command.

When asked to identify which well exceeds safe lead thresholds, the agent searches for "lead concentration." However, the simulation report lists the element under its chemical abbreviation "Pb" within a deeply nested table header. The agent's search returns zero results. Instead of adjusting its search query to check chemical symbols, the agent assumes lead was not detected and falsely reports that all twenty wells meet safety standards. The simulation held the correct answer, but the file retrieval step caused a total system failure.

Related gear

We recommend this book because it explains how retrieval, indexing, and data pipelines affect software reliability across complex systems.

AdvertisementAmazon

Designing Data-Intensive Applications

★★★★★ 4.8

Sources

  1. [1]arXiv — Same Simulation, Different Evidence: Where Retrieved Tool Output Costs LLM Agents Accuracy
  2. [2]USGS — PHREEQC Interactive Software Overview