As coding agents become more capable, the obvious form of improvement to think about is choosing a better model. A more capable model should reason better, understand more complex instructions, and produce better code.
But while the model is an important part of the results produced, the tools available to it and the quality of the information those tools return play the other crucial part.
We wanted to understand the functioning of these tools more closely at Metaphor. Our initial objective was to evaluate how effectively our coding agent used its tools: whether it selected appropriate tools, invoked them correctly, interpreted their results, and completed tasks without unnecessary investigation.
We started with what seemed like a relatively straightforward question: could we measure the performance and efficiency of tool calls for Metaphor’s coding agent?
Well, tool usage is not as straightforward as our question seemed. It’s more than counting calls or checking whether the agent selected the expected tools.
As we conducted the experiment, the quality of the investigation depended on the task, the evidence available, the capabilities of individual tools, and how the agent adapted when the evidence was incomplete.
The task type and tool calls relationship
One of the first patterns we observed was how differently agents approach tasks depending on how precisely those tasks are described.
When a task explicitly mentioned the investigation method, for example, using a search operation followed by reading the relevant file, the agent generally followed that sequence. While this seems obvious, we set this as a baseline for establishing the working of the tools, like a control arm.
When the same underlying objective was written more naturally, the agent was less consistent about the exact sequence. Two of three runs used the same search-and-read approach, while another used a retrieval tool followed by a read.
The difference became more pronounced when the task itself was ambiguous. For an open-ended request to explain how a specific functionality in the codebase worked, all three runs combined multiple investigation methods: repository retrieval, file discovery, text search, and file reading. All nine runs completed successfully.
This is an important distinction. More tool calls did not necessarily indicate worse performance.
A narrowly defined task often has a relatively obvious investigation path. An architectural question, especially one that spans across multiple files, requires understanding relationships across all the files and hence more complex to find all the parts of code relevant to it.
The task therefore influences not only which tools are useful, but also how much investigation is justified.

The experiment suggested that an agent's investigation strategy was to be evaluated relative to the task rather than against one universally preferred sequence.
This also plays into how we should think about efficiency. A tool call that is unnecessary for a narrow task may be essential for a broader one. Without considering the task, call counts alone tell us very little.
More context is not always better context
A second recurring pattern was the tendency to combine overlapping context-gathering tools.
An agent might use a repository-level retrieval tool, then perform additional file discovery and text searches, and finally read several files.
Sometimes these operations provide complementary information. Other times they retrieve a fair bit of overlapping evidence.
We tested whether simply asking the agent to avoid unnecessary context gathering would reduce or suppress this behavior. In one experiment the rate of retrieval-plus-search remained exactly the same in both the control and treatment groups, which was six out of ten runs.
We ran a more specific experimental update, focused on continuing only when the available evidence was insufficient, which produced a different result in selected scenarios. In one comparison, the average number of context-tool entries fell from 3.0 to 1.5.
Generic instructions to be more efficient did not reliably change behavior. But more specific guidance about evidence sufficiency sometimes did.
We also found that the same tool combination could be justified in one task and redundant in another. A retrieval operation might identify the relevant component, while a subsequent search locates a particular function or relationship that the initial result did not expose.
Removing that second operation simply because it increases the call count could leave the agent with incomplete information.
The goal was not to simply reduce the tool calls. It was to minimize investigation that does not improve the evidence available to the agent.
Analyzing the tool output quality
As we examined more runs, it became clear that some behaviors initially attributed to the agent were actually consequences of the tools themselves.
An agent can only make decisions based on the information it receives. If a retrieval tool missed a relevant file, returned an incomplete snippet, or ranked unrelated content highly, the agent compensated by searching again or reading more files. From the agent's perspective, this additional investigation can be entirely reasonable.
This led us to examine retrieval and search behavior independently of the agent's reasoning.
We found potential improvements that affected the quality of evidence returned by these tools. Exact identifier searches could fail to surface relevant files even when the identifier was present. Some natural-language queries returned noisy matches. Search results could also contain only a declaration or signature when the implementation required surrounding lines to understand.
They proved to be not tool selection and reasoning failures as much as it proved to be the extraction of the results from it.
One particularly useful lesson was that retrieval and exact code search solve related but different problems.
Retrieval is useful for discovering potentially relevant context, especially when the task is described conceptually. Exact search is often more suitable when the question concerns a particular identifier or implementation detail. Reading the file then provides the surrounding code needed to verify the result.
No single tool was consistently superior across all the tasks we tested.
In a comparison, both repository-context retrieval and codebase retrieval independently completed all eight runs assigned to them. For an architecture task, however, one approach required substantially fewer calls than the other in that particular ablation.
While we can’t say this applied universally as a rule, it did show that tool suitability depends on the information being sought.
A broader lesson emerged: an agent's apparent inefficiency may originate upstream, in the quality of the evidence returned by its tools.
Balancing precision and recall
Improving retrieval quality introduced another trade-off: precision versus recall.
A retrieval system needs to surface relevant files without overloading the agent with unrelated matches and context. Returning too many irrelevant results makes it harder to identify useful evidence. Filtering too aggressively on the other hand, can hide files that are genuinely relevant.
We explored this through a set of 24 scenarios covering exact identifiers, natural-language query led discovery, configuration and package questions, multi-file architecture, noisy queries, and technical vocabulary.
The results showed a substantial improvement in precision across the tested conditions.

The expanded filtering condition substantially improved precision and ranking quality in this test corpus. It also eliminated the noisy matches observed in the dedicated stress scenarios.
But the result came with a trade-off. Recall on scenarios with expected files decreased from 0.783 to 0.750. One natural-language discovery query that previously returned several files returned no results under the expanded filtering condition.
This is why precision and recall need to be considered together. A retrieval system that returns only highly relevant results can still fail if it omits the file the agent needs. That is high precision but lower recall.
We also found that improving retrieval quality did not automatically reduce the number of file reads or the overall cost of an investigation. In the live runs, tool usage and cost remained broadly similar. The improvement was in the quality and ordering of the evidence, not a demonstrated reduction in execution cost. A better retrieval can make an agent more reliable without necessarily making it cheaper or faster.
Tool usage analysis beyond task completion
Task completion is an insufficient measure of tool quality. An agent can complete a task while using an unnecessarily broad investigation strategy. It can also select the right tool but invoke it with arguments that return poor results. Conversely, it can make a reasonable tool selection and still fail because the underlying tool does not expose the required information.
A useful evaluation mental model we came up with based on our experimenting to think about this evaluation:

These questions also helped explain why a successful final answer does not necessarily mean the investigation was optimal.
For example, an agent may recover from a weak retrieval result by using additional search and file-reading operations. The task succeeds, but the initial tool call may still have been ineffective.
Likewise, a low number of calls is not inherently a positive outcome. If the agent stops before finding the necessary implementation details, the investigation is efficient only in the narrowest sense.
We therefore considered the overall use of tools across all these factors between the task, the investigation path, the evidence obtained, and the final answer.
We also concluded that different tasks have different acceptable strategies. A single expected sequence of tool calls is often too restrictive for autonomous systems. Multiple investigation paths may be equally valid, provided they produce sufficient evidence and a correct result.
What we changed and what remains open
The experiments ultimately led us to make several targeted improvements to the tools themselves. We improved how exact code identifiers are queried and identified by the tool calls, refined retrieval behavior to reduce low-value matches, and corrected an issue in how surrounding code context was returned during searches.
These changes were validated through focused tests and subsequent live agent runs. The final post-cleanup smoke evaluation completed four out of four runs successfully, with no infrastructure failures. The focused unit tests also passed.
The specific changes behaved as intended in the tested cases.
We did not demonstrate a significant reduction in overall tool calls, latency, or cost from these changes. However, that was expected as it was not the intended outcome of this particular experiment.
Some questions we particularly look to continue to dig deeper into for further improvement among many others are:
How should an agent decide that it has gathered enough evidence?
Can it recognize when two tools are returning overlapping information?
How should it adapt its investigation strategy when a task moves from locating a function to understanding a broader system?
These questions become increasingly important as coding agents move beyond single-file edits and take on larger, more autonomous engineering tasks.
