Skip to content

Add TOON adapter for token-efficient model context injection (RFC 0050)#53

Merged
supernovae merged 2 commits intomainfrom
feat/toon-adapter
Apr 18, 2026
Merged

Add TOON adapter for token-efficient model context injection (RFC 0050)#53
supernovae merged 2 commits intomainfrom
feat/toon-adapter

Conversation

@supernovae
Copy link
Copy Markdown
Owner

Summary

  • RFC 0050 defines TOON (Token-Oriented Object Notation) as an opt-in wire format for model-facing context injection, achieving ~20-40% token reduction vs JSON while preserving JSON Schema as the normative interchange and audit format.
  • Core adapter (harness/src/adapters/toon-adapter.ts) provides toToon, fromToon, and schemaToToonHeader with round-trip fidelity against Ajv validation.
  • Manifest integration adds manifestToToon and a serializeManifest dispatcher alongside the existing manifestToCompactText, selected via a new wireFormat config option on governed-agent and chat-agent.
  • Research-backed: cites arXiv 2603.03306 (TOON benchmark), arXiv 2604.05865 (JTON, 15-60% reduction), ATON V2 whitepaper (56% reduction), and Abt 2025 (TOON design rationale). All added to docs/bibliography.md and docs/related-work.md.
  • Documentation: updated docs/token-efficiency.md with Tier 2.5 section, experiment card at docs/experiments/toon_format_efficiency.md, side-by-side JSON/TOON fixtures in examples/toon/.

Test plan

  • 25 new tests in harness/tests/toon-adapter.test.ts covering serialization, parsing, round-trip, schema headers, manifest TOON output, and the serializeManifest dispatcher
  • Full harness test suite passes: 114/114 tests, zero regressions
  • Default behavior unchanged — wireFormat defaults to "compact-text"
  • Review RFC 0050 for spec completeness
  • Review TOON example fixtures for clarity
  • Run governed-agent demo with wireFormat: "toon" against a live backend

Made with Cursor

TOON (Token-Oriented Object Notation) is an opt-in wire format that
reduces token consumption by 20-40% compared to JSON for structured
harness payloads. JSON Schema remains the normative interchange and
audit format; TOON is strictly an adapter-layer optimization.

- RFC 0050: specification, notation reference, research citations
- harness/src/adapters/toon-adapter.ts: toToon, fromToon, schemaToToonHeader
- manifestToToon and serializeManifest dispatcher in manifest-builder
- wireFormat config option on governed-agent and chat-agent
- 25 new tests (114 total, zero regressions)
- Experiment card, example fixtures, bibliography and docs updates

Made-with: Cursor
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 18, 2026

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Comment thread harness/src/adapters/toon-adapter.ts Fixed
Comment thread harness/src/adapters/toon-adapter.ts Fixed
- Replace polynomial regex in scalarArrMatch (remove \s* before .+
  capture group, trim after match instead)
- Replace polynomial regex in isObjectKeyLine (use indexOf + bounded
  character class instead of unbounded .* with trailing \s*)
- Fix strict TypeScript error in schemaToToonHeader by narrowing
  properties to a local variable after the guard check
- Skip cross-schema example folders (toon/) in validate.py to avoid
  false-positive unknown-folder errors

Made-with: Cursor
@supernovae supernovae merged commit 0b3bc14 into main Apr 18, 2026
10 of 11 checks passed
@supernovae supernovae deleted the feat/toon-adapter branch April 18, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants