How we make AI coding more cost efficient without sacrificing task quality

Erik Kristensen, Napalys Klicius2 Sep 2026

Problem

Teams that run coding agents pay for model tokens on every turn. The common fix is to shorten each tool response. A shorter response can hide detail the agent needs, so the agent rereads output, reruns commands and carries a longer context into every later turn. The saving on one call becomes a higher cost for the whole task. GitHub Copilot needed lower cost at equal task success.

Example from the article: the team tested RTK, a utility that shortens shell output. In their setup it shortened some responses, but the model often reopened the original output or reran the command, so the task used more tokens and took longer.

Solution in brief

Optimize the completed task, not the tool call. Every candidate change goes through offline agentic coding benchmarks and then a controlled online experiment on the same cost metric. Four changes passed: compression that keeps useful output, dropping unused line-number prefixes, a shorter task-tool prompt guarded by a behavior test, and batched delivery of background results.

Questions this case answers
  • How to lower the inference cost of a tool-using LLM agent per completed task when trimming individual tool outputs or prompts may force extra recovery turns
  • How to validate an agent efficiency change offline and online so that a local token saving is not a global cost increase
  • How to reduce the cost of an AI coding agent per completed task without lowering task quality?
  • How to tell whether shortening tool output or prompts really saves money, or only moves the cost to extra agent turns?

Tools and methods

  • Offline agentic coding benchmarks — screen each change for success and cost
  • Online A/B experiments on AI Credits — confirm the saving on real users, with quality guardrails
  • Selective output compression with a recovery path — compress only repetitive noise and keep the full original reachable
  • Meta-prompting loop plus behavioral tests — shorten prompts, check preserved behavior
  • GitHub Copilot CLI — where the changes were measured
Continue reading — it's free

Google or a one-time email code. No password.