GitHub published a breakdown of how it reduced the cost of running Copilot's coding agents across a complete task, rather than optimizing any single tool call, according to its own engineering blog.

Four changes drove the savings: selective output compression cut costs 5.5%, removing unused line-number formatting saved 3.1%, prompt optimization saved 2.9%, and batching background task completions saved 2.3%, GitHub said.

The team's early attempt at aggressive output compression backfired, making models repeat work and increasing total cost, so the final approach preserves source code output and keeps a recovery path for compressed content, according to the post. A separate attempt to shorten prompts broke the model's ability to parallelize work; a one-sentence revision restored it while keeping the savings.

"The goal shouldn't be to use fewer tokens, but to tap into the right amount of context to move a task forward," the team wrote. Every change was validated with offline benchmarks and controlled online A/B tests before shipping, and some changes that helped one Copilot product increased costs in another, GitHub said.

Anyone running an agent in production is fighting the same instinct GitHub describes here: shorter output looks cheaper on the invoice but can cost more once an agent has to redo work it should have gotten right the first time. Measuring the full task, not the token count, is the harder but more honest way to tune agent cost.