Menu
GitHub Engineering·July 10, 2026

Optimizing AI Agent Workflows for Code Review Efficiency

This article details how GitHub improved the efficiency of Copilot code review by refining the AI agent's workflow rather than just upgrading its underlying tools. By explicitly guiding the agent to adopt a reviewer-like thought process—starting from the diff, narrowing searches, and batching reads—they achieved a 20% reduction in review cost while maintaining quality. This highlights the critical role of prompt engineering and workflow design in system design, especially for AI-driven components.

Read original on GitHub Engineering

The GitHub Engineering article explores an intriguing challenge in optimizing an AI agent: improving Copilot code review's performance. The initial instinct was to upgrade the agent's code exploration tools, replacing custom tools with a shared, better-maintained set (grep, glob, view) from the Copilot CLI. However, this led to increased costs and reduced effectiveness in benchmarks.

The Problem: Generalist Tools vs. Specialist Task

The core issue was a mismatch between the general-purpose nature of the new tools and the specific task of code review. The shared tools were designed for broad repository exploration, leading the agent to behave like a "browsing assistant"—widening searches, guessing paths, and accumulating excessive context. This contrasts sharply with how a human reviewer operates: starting from the diff, asking targeted questions, and seeking minimal, relevant context.

ℹ️

Impact of Excess Context for AI Agents

For an AI agent, every tool result (e.g., file contents) becomes part of its working context, consuming tokens and increasing processing cost. Crucially, it can also dilute focus, making the review less effective by introducing irrelevant information into the decision-making process.

The Solution: Workflow-Centric Prompt Engineering

Instead of changing the tools, the team redesigned the agent's instructions to align with a reviewer's workflow. The new guidance emphasized: a) starting from the diff, b) forming specific review questions, c) using `glob` and `grep` for narrow discovery, d) batching cheap discovery operations, and e) using `view` only for focused reads of known file/line ranges.

plaintext
Generic Posture: Use tools to inspect relevant repository context.

Review-Shaped Guidance:
1. Start from the diff.
2. Narrow first with grep and glob.
3. Read exact evidence with view.
4. If grep fails, retry with simpler search.
5. If path is wrong, pivot to glob, not guessing.
AI agentscode reviewprompt engineeringworkflow optimizationsystem designdeveloper toolsLLM operationstooling

Comments

Loading comments...