Token counts are the wrong yardstick for agent efficiency
When working with AI coding agents, token count per interaction is not a meaningful efficiency measure. The real goal is moving a task forward with the right context — not reducing tokens at any cost. Concise output that strips needed information forces the agent to make extra calls or rerun commands, ultimately making the task slower and more expensive.
GitHub Copilot shipped four changes reflecting this principle: preserving useful context while cutting repetitive output, removing unused formatting, compressing prompts without losing behavior, and delivering completed background work without requiring an extra retrieval step. Each change was first evaluated offline using agentic coding benchmarks, then validated through controlled online experiments. Examples below come from GitHub Copilot CLI, but the underlying harness is shared by the Copilot app and Copilot code review.

Why short tool output can cost more globally
Utilities such as RTK (Rust Token Killer) shorten shell output before an agent reads it. Tested with the Copilot agentic benchmark configuration, RTK shortened some responses, but when omitted text mattered, the model sometimes reopened the original output or reran the command to recover what it needed. Those recovery steps added turns and carried more context forward. Individual tool responses were shorter, but tasks on average used more tokens and took longer. Tokens were saved locally and spent globally.

This result is specific to the integration and workloads tested, not a blanket judgment on RTK or output compression. The lesson is that tokens per tool call is the wrong objective; efficiency changes must be evaluated end-to-end, from user request to final result. The useful question is what can be removed without making the model repeat work.
Selective compression: remove noise, keep information
Analysis of benchmark runs showed that install, build, test, and lint output often contains repetitive noise, while source-like output and arbitrary command results are more likely to hold information an agent needs. That informed a selective output compressor, in part inspired by RTK and similar tools. It was evaluated on agentic benchmarks and open source repositories exercising their build, test, and lint systems.
Early versions were too aggressive and made the model repeat work or read full saved output, raising end-to-end cost and hurting task success. Compressing git diff was removed from the filter set after agents reopened the original output to recover missing information. Iteration led to a three-part policy:
- Preserve source-like and arbitrary output. Commands such as
cat,git diff,git show, and arbitrary scripts come back unchanged. - Reorganize search results without dropping content. Matches and file lists from
grepand similar tools are grouped more efficiently while retaining every result. - Compress repetitive noise selectively. Install, build, test, and progress output is compressed only when savings are substantial.
The shipped version is conservative — not because conservatism was a goal, but because evaluations supported it. When output is compressed, the agent retains a direct recovery path to the complete original.

Recovery rate was tracked as an evaluation signal: if the agent opened saved originals, reran commands, repeated exploration, or took extra turns, the compressor likely removed something valuable. On offline tasks where compression triggered, no statistically significant task-success regression was detected and agents very rarely opened saved originals. In the online experiment, average cost decreased slightly with no material quality regression.
Line numbers removed from a tool that didn't use them
The view tool, used by agents to read files into context, previously prefixed each line with a number. Earlier file-editing tools relied on those numbers to target changes, but current tools match on surrounding code instead. The prefixes persisted even though the normal workflow no longer used them. Small per-line, the wasted formatting accumulated across every file read in a session.

Line numbers remain useful in diffs and short snippets, but attached to every file read they served no current purpose. Removing them cut model-inference cost roughly 5% in offline agentic benchmarks, with success rates staying within run-to-run variance and no increase in edit failures. A Copilot CLI online experiment confirmed the results: about 3% lower average daily model-inference cost per user, with no material quality or satisfaction regression. Developers gain more context window for real work instead of unused formatting — no new instructions, no information to recover, no decisions for the model.
Shorter prompts only work if behavior survives
Prompts shape agent behavior and go to the model every turn. Compression only pays off if the agent keeps essential behaviors. In GitHub Copilot, the task tool's guidance had accumulated across tool descriptions, schemas, agent definitions, system instructions, and companion tools. A meta-prompting loop, iterating on its own prompt with targeted behavioral tests, reduced it by roughly half.
The first online experiment caught a regression initial offline evaluations missed: the loop rewrote cautious parallelism guidance into a hard scheduling policy, causing independent custom agents to run sequentially. The experiment was stopped and a regression evaluation written for the exposed behavior. The fix replaced an explicit allowlist and denylist with one sentence:
Independent agents can run in parallel; consider side effects.
That one line was shorter and less restrictive, deferring the parallelism decision to the model. The behavior test passed, existing behavioral tests stayed green, and the shipped prompt removes about 1,300 task-tool prompt tokens per turn — about 1.8% fewer total prompt tokens per session and 2.9% lower normalized cost per active hour, with no quality regression.

Deliver results; don't make the agent fetch them twice
Agents often run independent work in the background — a long shell command beside a sub-agent investigation. Notifications let the agent proceed until work finishes. Previously, a completion notification did not include the result, forcing the agent to spend another turn retrieving output the harness already had. When several tasks finished close together, that detour repeated. Completion notifications are now batched, and results are delivered directly in the existing tool-result format. Explicit reads for work still running behave as before.

Previously, each completed task required one model call to request its result and another to process it, meaning four model calls for a shell command plus sub-agent before work could continue. Now both completions arrive batched, so one model call processes everything. Removing those retrieval detours also avoids carrying full session context through unnecessary calls. Without compressing, summarizing, or withholding content, this reduced average token-related usage, measured in AI Credits, by about 2.3%.
What works in one workflow fails in another
A tighter set of file-tool instructions, inspired by positive results in Copilot code review, increased cost in a Copilot CLI online experiment and was not shipped. In contrast, removing line-number prefixes and selective output compression each reduced average prompt tokens per review by roughly 5% in independent evaluations across code review tasks using the production model, with no material change in tracked quality metrics. These results are separate from an earlier migration of code review to shared file tools which, combined with review-instruction tuning, reduced code review cost by about 20%. Changes must be measured where they run.
Rules for building efficient coding agents
- Optimize the completed task, not the tool call. Shorter output isn't cheaper if the agent spends extra turns recovering what was removed.
- Optimize orchestration, not just model output. Eliminate model turns for work the harness can finish deterministically.
- Compress by what the output represents. Preserve exact content, prefer lossless transformations, and track how often agents use the recovery path.
- Prompt rewrites can have unintended consequences. Validate that intended behaviors are preserved.
- Evidence is workload-specific. Re-evaluate changes in offline benchmarks, online experiments, and across every product surface.
None of these changes made the model smarter. They removed work the model never needed to do, including delivery of completed background work without retrieval detours and, across GitHub Copilot products using the same harness, selective compression, the unneeded line numbers, and the lighter prompt. The cumulative effect is fewer model turns, less redundant context, and more context budget devoted to actual engineering.



