Skip to main content

What is TOON?

TOON (Token-Oriented Object Notation) is a compact data serialization format designed specifically for LLM prompts. It encodes structured data using 40-50% fewer tokens than JSON while remaining human-readable and LLM-parseable. ArgentOS uses TOON throughout the system wherever structured data needs to be injected into agent prompts.

Why Not Just Use JSON?

Every token in an LLM prompt costs money and takes up context window space. When you inject a 50-item task list or a 20-step workflow history into an agent’s prompt, JSON’s verbosity adds up fast: TOON achieves this by using a tabular format for uniform arrays, eliminating repeated keys, and using minimal delimiters.

Where ArgentOS Uses TOON

TOON is integrated into 9 core systems via src/utils/toon-encoding.ts:

Workflow Pipeline Context

When an agent step runs inside a workflow, it receives the full pipeline history encoded as TOON:
This gives each agent full awareness of what happened before it, using a fraction of the tokens that JSON would require.

Agent Handoffs

When one agent passes work to another in a multi-agent workflow:

Memory Recall Results

When the agent recalls memories, results are TOON-encoded before injection:

SpecForge Task Breakdowns

When SpecForge creates atomic tasks for a project:

Other Integration Points

  • Knowledge Library results — RAG search results encoded for prompt injection
  • Team status — multi-agent family status updates
  • Tool results — uniform tool output arrays (search results, file listings)
  • SIS active lessons — self-improving system lesson injection
  • Cron definitions — scheduled task summaries

How It Works in Code

The encoding layer at src/utils/toon-encoding.ts provides typed functions:
All functions fall back to compact JSON if TOON encoding fails for a particular data structure.

Decoding

TOON content can be decoded back to structured data:
Falls back to JSON.parse if TOON decoding fails.

Learn More