Token Efficiency Encyclopedia

Token-Aware Formatting

Remove unnecessary whitespace, comments, or metadata. Use shorter variable names in code contexts. Avoid repeating system instructions on every turn if the provider supports prompt caching.

How It Works

The prompt is formatted to minimize token count without changing semantic meaning. Techniques include stripping redundant whitespace, abbreviating identifiers, removing boilerplate comments, and deduplicating repeated instructions.

Techniques

Tool-Output Artifacts

Tool results are formatted once by the harness and then re-sent on every later turn, so any decoration in them is paid for repeatedly. Some of it was once load-bearing and outlived its purpose: GitHub Copilot's agent prefixed every line of a file read with its line number, a convention from an older edit tool that addressed lines by number. The current edit tools match on text, so the prefixes were pure overhead. Removing them cut model-inference cost by about 5% offline and 3% online, with no change in edit success rate (GitHub blog, 2026).

The audit question for every piece of tool-output formatting: which tool or instruction reads this? If the answer is none, drop it. Keep only what the model uses to act — a line number is worth its tokens if the edit tool takes line numbers, not otherwise.

Command-line tools have the same problem at the source: git, ls, test runners, and package managers print for humans. A proxy that rewrites their output into a compact form before it reaches the model applies this technique without changing the agent — see rtk below.

Trade-offs

When to Use

Best for code-heavy prompts where the model needs the logic, not the presentation. Less useful for natural-language tasks where tone and structure matter.

See Also

Tools