AI
Optimize AI Coding Agents by Rethinking Tool Output Format
How agents consume data—not just models or prompts—drives token costs in AI-assisted development.
The New Stack
Most of the tokens an AI coding agent consumes happen before it writes any code. Source files, build logs, security findings, and dependency data all add up—often far exceeding the cost of the pull request itself. While teams typically optimize by choosing cheaper models or trimming prompts, a less obvious lever sits in how developer tools package information for agents to read.
The Hidden Cost of Repetitive Structure#
When tools return large datasets as JSON, every single record repeats the same field names, quotation marks, and structural overhead. An agent examining 25, 100, or 500 security findings sees "severity," "component," and "status" hundreds of times over. This repetition burns tokens without adding information, crowding out context that could hold actual evidence or source code instead.
Consider a typical issue record:
{
"key": "AZ1002fQ9x",
"severity": "BLOCKER",
"component": "src/main/java/com/acme/UserRepo.java",
"line": 29,
"status": "OPEN"
}
Scaling this to dozens or hundreds of findings means the agent pays to re-read those labels repeatedly. The data is valuable; much of its representation is not.
A Compact Alternative for Uniform Data#
Token-Oriented Object Notation (TOON) addresses this by adopting a schema-once, rows-many approach. Field names appear in a header, then each record becomes a lightweight row. The encoding is lossless—no information is lost—but the structural overhead vanishes.
Beyond smaller file size, a regular, predictable structure helps agents validate fields and make more confident decisions. The agent sees the same findings with less scaffolding around them.
Measure Your Own Workflow#
Rather than relying on generic benchmarks, teams should test on real output. Character count is a useful signal, but tokenization varies across models. The practical approach: capture a representative response from your tools, run it through your model's tokenizer, and compare the two formats.
A concrete example showed TOON using 49% fewer characters than pretty-printed JSON and 33% fewer than minified JSON on a 25-issue sample. The TOON project's published benchmarks also report lower token usage for tabular datasets. However, these should guide testing, not replace measuring your own production payloads.

