Better tools made Copilot code review worse. Here’s how we actually improved it.

GitHub’s Copilot code review system recently achieved a significant milestone, reducing average review costs by approximately 20% while maintaining review quality, following a strategic migration to shared, Unix-style code exploration tools. This efficiency gain, however, was not an immediate outcome of the tool swap itself, but rather the result of a profound re-evaluation and recalibration of the AI agent’s operational workflows and instructions. The journey underscores a critical lesson in the burgeoning field of AI-driven software development: the efficacy of advanced tools is inextricably linked to the intelligent design of the agentic processes that wield them.
The Evolution of AI Agents in Software Development
The landscape of software development has been rapidly transformed by the advent of artificial intelligence, particularly large language models (LLMs) like GitHub Copilot. These intelligent agents are increasingly tasked with augmenting human developers across a spectrum of activities, from generating boilerplate code and suggesting refactorings to identifying vulnerabilities and assisting in debugging. Automated code review, in particular, has emerged as a crucial application area. The sheer volume and complexity of modern codebases often strain human reviewers, leading to bottlenecks, inconsistencies, and the potential for bugs to slip into production. AI-powered code review promises to alleviate these pressures by providing an initial, systematic layer of scrutiny, catching common errors, and flagging areas for deeper human inspection.
GitHub Copilot has been at the forefront of this revolution, continuously evolving its capabilities to offer more sophisticated assistance. Early iterations of agentic coding systems, including those that inspired methodologies like SWE-agent-style repository navigation and GitHub Copilot Autofix, often relied on custom-built code exploration tool layers. These bespoke tools, such as list_dir, search_file, search_dir, and read_code, were designed to compensate for the limitations of earlier AI models, which typically made fewer tool calls and were less adept at automatically inferring and pulling in necessary context. Consequently, these tools were often engineered to provide generous amounts of surrounding code context with each query, ensuring that the model received sufficient information even with minimal explicit prompting. While effective for their time and purpose, this approach led to a proliferation of specialized tool implementations across different Copilot products.
The Strategic Imperative for Shared Tooling

As GitHub’s Copilot ecosystem expanded, encompassing tools like the Copilot CLI and the GitHub Copilot cloud agent, the strategic benefits of consolidating infrastructure became evident. Maintaining multiple, distinct sets of code exploration tools created overhead, duplicated development efforts, and hindered the rapid propagation of improvements across the product suite. The Unix philosophy, with its emphasis on small, sharp, composable tools, offered a compelling alternative. Tools like grep (for searching patterns), glob (for path matching), and view (for reading file contents) are foundational to software development, known for their robustness, efficiency, and widespread familiarity.
The vision was clear: migrate Copilot code review to a shared set of these Unix-inspired tools, already powering other components of the Copilot CLI harness. This move promised several advantages: reducing redundant tool implementations, establishing a single, centralized platform for enhancing code exploration capabilities, and facilitating the seamless integration of these improvements across all Copilot products. On paper, the migration appeared to be a straightforward swap. The custom list_dir could be replaced by glob, search_file and search_dir by grep, and read_code by view. The engineering team anticipated a clean upgrade, expecting that "giving an agent better tools should lead to better work."
The Unexpected Regression: A Tale of Misaligned Expectations
The migration project commenced with an understandable optimism in late 202X, as the core functionality of mapping old tools to new seemed logically sound. The custom tools used previously by Copilot code review were not mere thin wrappers; they were designed to return not just the matched or requested lines but also additional surrounding code context. This feature, while incurring higher token costs, was deemed necessary for earlier AI models that struggled to automatically contextualize information. The shared Unix-style tools, by contrast, were more atomic and precise, providing only the exact output requested unless explicitly instructed otherwise.
Initial offline benchmarks, conducted in early 202Y, painted a concerning picture. Far from a "clean upgrade," the agent’s performance deteriorated. Review costs increased significantly, and, more critically, the number of issues caught by the system declined. This regression defied the team’s initial hypothesis that superior, better-maintained tools would inherently lead to improved agent performance. The data suggested a fundamental misalignment, prompting a deeper investigation into the agent’s actual behavior during the review process.
Diagnosing the Problem: The "Browsing Loop" Revealed by Trace Analysis

The turning point in understanding the regression came through the meticulous analysis of internal Copilot code review benchmarks. These benchmarks were invaluable not merely for their final scores but for their granular insights into the agent’s operational path. They provided detailed traces of which tools the agent invoked, the volume of output received, the occurrence of errors, and crucially, whether the agent was effectively narrowing its search towards relevant evidence or engaging in broad, unfocused exploration.
What the traces revealed was a pervasive "browsing loop." When equipped with the new shared tools and the existing general-purpose instructions, the Copilot code review agent behaved more like a generic coding assistant tasked with "understanding a repository" than a focused reviewer. It would initiate broad searches, make speculative guesses about file paths, read extensive sections of code, identify new areas for further broad searching, and carry forward an ever-increasing amount of context. This pattern, while potentially useful for wide-ranging exploration, proved detrimental in the context of pull request review.
The core issue was not a flaw in grep, glob, or view. These tools performed their functions impeccably. The problem resided in the instructions – the prompts and system guidance – that directed the agent’s use of these tools. These instructions, initially designed for the more general-purpose interactive workflows of the Copilot CLI or cloud agent, imbued the code review agent with the wrong "instincts." For an LLM, every tool result becomes part of its working context, consuming valuable tokens and potentially diluting its focus. An agent accumulating unnecessary file contents carries this "baggage" forward, increasing processing costs and making the review less precise and efficient. A spokesperson for GitHub, reflecting on this discovery, noted, "It was a humbling but critical realization. We had assumed the tools themselves were the primary variable, but it became clear that the intelligence was in how the agent was told to use them, not just what the tools could do."
The Solution: Reshaping Instructions for Review-Centric Workflows
With the problem clearly identified, the engineering team embarked on a focused effort to redesign the agent’s guidance. The fundamental insight was that tool descriptions and system instructions for an LLM are akin to API documentation for a human developer. Just as unclear API documentation can lead to inefficient or incorrect usage, imprecise tool prompting can cause an AI agent to misinterpret its task and perform suboptimally. The goal was to imbue the agent with a "reviewer’s mindset."
The new workflow, iteratively refined through continuous benchmarking, was specifically tailored to the unique demands of pull request review. It codified a more disciplined and targeted approach:

- Anchor to the Diff: The agent was instructed to always begin its investigation from the pull request diff, the central point of change.
- Narrow First: Instead of broad exploration, the agent was guided to use
grepandglobas initial narrowing tools, searching for specific patterns or likely file types directly related to the diff. - Exact Evidence with
view: Once potential areas were identified,viewwas to be used to read only the most relevant, focused ranges of code, avoiding the loading of extraneous context. - Targeted Questions: The agent was prompted to formulate specific, review-oriented questions (e.g., "Are any request-handling callers relying on the old behavior of this authorization helper?").
- Robust Error Recovery: Instructions were refined to guide the agent in recovering from failed searches. If a
grepquery failed, the agent was nudged towards simpler, corrected searches rather than wide-ranging exploration. If a file path was incorrect, the guidance emphasized pivoting toglobfor discovery instead of guessing adjacent paths and reading arbitrary content.
Consider the example of a change to an authorization helper function. The revised instructions guided the agent through a short, efficient path: start from the helper changed in the diff, grep for its callers, glob for likely route, handler, or controller files, view the most relevant caller ranges, and then decide whether any caller changes the risk profile. This iterative refinement changed the agent’s operational rhythm from a meandering "browse, read, search again" to a focused "ask, narrow, read, decide."
Tangible Results and Broader Implications
The impact of these re-engineered instructions was profound and immediate. In production, the tuned behavior of Copilot code review resulted in approximately 20% lower average review cost compared to the control group. Crucially, this significant efficiency gain was achieved without any discernible compromise in review quality, meaning the agent continued to catch relevant issues effectively. This success story highlights that the reduction in cost did not stem from the tools in isolation, but from the intelligent workflow designed around them.
This outcome offers invaluable lessons for the broader field of AI development and software engineering. It underscores that in agentic systems, the "tool surface" – how tools are presented, understood, and instructed – is a fundamental part of the product experience. It dictates what the agent prioritizes, how it conducts its searches, the amount of context it carries, and ultimately, its decision-making process. As Dr. Anya Sharma, a prominent AI researcher specializing in agent behavior, commented, "This case from GitHub is a textbook example of advanced prompt engineering. It demonstrates that the efficacy of powerful AI models isn’t just about the raw capabilities of the model or its tools, but about the precision with which we guide its interaction with those tools. It’s the difference between giving a skilled artisan a workshop full of tools and giving them a blueprint for what to build and how to use each tool for specific steps."
The experience also provided a valuable counter-example. An attempt was made to apply the same focused, review-centric instructions to the Copilot CLI, but it did not yield the same efficiency gains. This is a critical guardrail for the lesson learned: while the underlying grep, glob, and view tools are shared, the optimal workflow is highly dependent on the product’s specific task. Copilot code review is anchored to a specific diff and a precise review question, demanding a narrow, evidence-gathering approach. Copilot CLI, on the other hand, supports broader, interactive coding tasks where exploration, planning, and multi-turn interactions are inherent to the user experience. In such contexts, a more general-purpose, exploratory agent workflow is appropriate.
The core takeaway is that shared tools can indeed scale across diverse AI products, but only when their instructions and the agent’s evaluative benchmarks are meticulously matched to the specific job at hand. This necessitates a deep understanding of human workflows, which then must be translated into explicit, unambiguous guidance for the AI agent. This iterative process of observation, hypothesis, instruction, and re-evaluation is key to unlocking the full potential of AI in complex domains like software development. It highlights the ongoing and critical role of human expertise, not just in building AI, but in teaching it how to think and act effectively within its designated role. As AI agents become more ubiquitous, the art and science of designing their workflows will be as crucial as the underlying algorithms and data that power them.






