Repository navigation
feat: Use TOON (Token-Oriented Object Notation) for LLM data serialization #1479
Copy link
Copy link
Open
Labels
area:ai-modelsAI model integration and configurationAI model integration and configurationenhancementNew feature or requestNew feature or requestmedium-priorityImportant but not urgentImportant but not urgentrefactorChanges needed to codeChanges needed to code
Description
Title:
Use TOON (Token-Oriented Object Notation) for LLM data serialization
Issue Body:
We should adopt the Token-Oriented Object Notation (TOON) format for passing structured data into/out of our LLM / agent workflows. TOON is a compact, schema-aware format that can reduce token usage by 30-60% versus standard JSON. :contentReference[oaicite:0]{index=0}
Motivation:
- Our current JSON-based payloads contain a lot of syntactic overhead (braces, quotes, repeated fields) which consumes tokens when sent to LLMs.
- By sending the same data in TOON format, we can reduce token cost, lower latency, and fit more data into the model’s input window.
- Since our architecture already uses JSON internally, the change surface is minimal — only the boundary layer (LLM-calls) needs conversion.
Proposed Solution:
- Introduce a serialization layer in our Node.js/TypeScript backend that converts JSON → TOON when preparing data for LLM calls, and TOON → JSON when parsing responses.
- Use the official NPM package
@toon-format/toonfor encoding/decoding. :contentReference[oaicite:1]{index=1} - Update our prompt templates to instruct the model to accept/produce TOON format (e.g., include a brief example header)
- Benchmark token counts, latency, and cost before and after adoption to validate savings.
- Provide rollout guidelines: use TOON for flat/uniform data structures (e.g., lists, records) — for deeply nested or irregular structures, continue using JSON (TOON may not always yield benefit) :contentReference[oaicite:2]{index=2}
Acceptance Criteria:
- Helper functions/modules exist that convert to/from TOON reliably.
- At least one real-world workflow has been migrated and demonstrates measurable token/cost savings.
- Documentation/guidance is available for engineers on when to use TOON vs JSON.
- No regression in model accuracy or handling of structured data.
Out of Scope:
- Replacing JSON for all internal service APIs or storage – this proposal covers only the LLM/agent boundary layer.
- Building a custom TOON parser from scratch – we leverage the existing supported library.
- Changing deeply nested or highly relational payloads until initial rollout of simpler structures is validated.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:ai-modelsAI model integration and configurationAI model integration and configurationenhancementNew feature or requestNew feature or requestmedium-priorityImportant but not urgentImportant but not urgentrefactorChanges needed to codeChanges needed to code
Activity
Crunchyman-ralph commentedon Dec 3, 2025
hell yeah dude !
@claude can you take care of this ?
claude commentedon Dec 3, 2025
Claude finished @Crunchyman-ralph's task —— View job •
claude/issue-1479-20251203-1231• Create PR ➔TOON (Token-Oriented Object Notation) Implementation Complete ✅
I've successfully implemented the TOON format for LLM data serialization as requested! Here's what was delivered:
Final Implementation:
@toon-format/toon)🎯 Key Deliverables:
Core TOON System:
Developer Experience:
scripts/toon-cli.jsfor enable/disable, testing, file conversion🚀 Usage Examples:
📊 Expected Benefits:
🔧 Intelligent Features:
🎁 Ready for Production:
Job run | Branch:
claude/issue-1479-20251203-1231feat: Implement TOON (Token-Oriented Object Notation) for LLM data se…
feat: Implement TOON (Token-Oriented Object Notation) for LLM data se…
E7lektronXF commentedon Sep 28, 2026
Before this lands, I measured how much TOON actually saves on task-master's own data. Disclosure first: I maintain bpp, another compact format, so I included it too. The numbers below are meant to help the decision, whichever way it goes.
Setup: the repo's own
.taskmaster/tasks/tasks.json, turned into the payloads MCP tools return today (createContentResponse→JSON.stringify(content, null, 2)). TOON via@toon-format/toonwith default options. Tokenizero200k_base(cl100k_basegives the same ratios).mastertag (93 tasks + subtasks)What stood out:
details,testStrategy), and nestedsubtasks/dependenciesarrays keep TOON out of its tabular mode. The 30–60% figures come from flat, uniform tables, which task-master rarely sends.On the issue's acceptance criteria:
encode(x, { keepOrder: true })keeps the exact order and still totals −15.3% vs current.js/bpp.js), byte-identical to Python in parity tests.Happy to share the script so anyone can reproduce this. If it's useful, I can also run a small accuracy check on these payloads for TOON vs bpp vs minified JSON.
taskmaster_comment.md