Skip to content

feat: add TOON output format for token-efficient LLM responses#145

Merged
aashari merged 1 commit intomainfrom
feature/toon-output-format
Nov 30, 2025
Merged

feat: add TOON output format for token-efficient LLM responses#145
aashari merged 1 commit intomainfrom
feature/toon-output-format

Conversation

@aashari
Copy link
Copy Markdown
Owner

@aashari aashari commented Nov 30, 2025

Summary

  • Add TOON (Token-Oriented Object Notation) as default output format, reducing token usage by 30-60%
  • Add outputFormat parameter allowing AI to choose between toon (default) and json
  • Update tool descriptions with cost optimization guidance and schema discovery patterns
  • Automatic fallback to JSON if TOON conversion fails

Changes

File Description
package.json Added @toon-format/toon dependency
src/utils/toon.util.ts New TOON encoder utility with JSON fallback
src/utils/toon.util.test.ts Tests for TOON utility
src/utils/jq.util.ts Added toOutputString(data, useToon) function
src/tools/atlassian.api.types.ts Added outputFormat parameter
src/controllers/atlassian.api.controller.ts Respects outputFormat parameter
src/cli/atlassian.api.cli.ts Added -o, --output-format CLI option
src/tools/atlassian.api.tool.ts Updated descriptions with cost optimization guidance

Output Comparison

TOON (default, 57% smaller):

[2]{id,name,key}:
  "327682",Codashop,SHOP
  "16711683",Codapay,PAY

JSON (optional):

[{"id":"327682","name":"Codashop","key":"SHOP"},{"id":"16711683","name":"Codapay","key":"PAY"}]

AI Guidance in Tool Descriptions

Tools now include:

  • Cost optimization warnings to always use jq filter
  • Schema discovery pattern (fetch one item first to explore fields)
  • limit parameter recommendations

Test plan

  • All 60 existing tests pass
  • New TOON utility tests pass
  • Curl tests verify TOON output works
  • Curl tests verify JSON output works with outputFormat: "json"
  • Lint passes
  • Build succeeds

Note

Introduces TOON as the default response format with optional JSON, adds CLI/output schema support, and updates tools/docs with cost-optimization guidance.

  • Output formatting:
    • Default TOON output for API responses with optional JSON via outputFormat.
    • New utils/toon.util.ts (dynamic import, JSON fallback) and toToonOrJson/toToonOrJsonSync helpers.
    • utils/jq.util.ts: add toOutputString to route TOON/JSON output.
    • controllers/atlassian.api.controller.ts: respect outputFormat across GET/POST/PUT/PATCH/DELETE.
  • CLI:
    • Add -o, --output-format to read/write commands in cli/atlassian.api.cli.ts.
  • Tools:
    • tools/atlassian.api.types.ts: add OutputFormat to schemas.
    • tools/atlassian.api.tool.ts: update descriptions with cost-optimization, schema discovery, and examples; minor path/examples tweaks.
  • Dependencies:
    • Add @toon-format/toon in package.json.
  • Tests:
    • Add utils/toon.util.test.ts for TOON/JSON fallback behavior.

Written by Cursor Bugbot for commit 540ae96. This will update automatically on new commits. Configure here.

- Add @toon-format/toon package for Token-Oriented Object Notation
- TOON is now the default output format (30-60% fewer tokens than JSON)
- Add outputFormat parameter to switch between 'toon' (default) and 'json'
- Update tool descriptions with cost optimization guidance
- Add schema discovery pattern guidance for AI to explore fields first
- Fallback to JSON automatically if TOON conversion fails

TOON format example:
  [2]{id,name,key}:
    "327682",Codashop,SHOP
    "16711683",Codapay,PAY

vs JSON:
  [{"id":"327682","name":"Codashop","key":"SHOP"},...]
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@aashari aashari merged commit 33ffa7b into main Nov 30, 2025
2 checks passed
@aashari aashari deleted the feature/toon-output-format branch November 30, 2025 19:15
github-actions bot pushed a commit that referenced this pull request Nov 30, 2025
# [3.1.0](v3.0.0...v3.1.0) (2025-11-30)

### Features

* add TOON output format for token-efficient LLM responses ([#145](#145)) ([33ffa7b](33ffa7b))
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 3.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant