Skip to content

feat(core): add ToonUtils for JSON to TOON format conversion and update FlowAiCopilot to use it#13380

Open
iitzIrFan wants to merge 12 commits intokestra-io:developfrom
iitzIrFan:feature/ai-copilot-toon-optimization
Open

feat(core): add ToonUtils for JSON to TOON format conversion and update FlowAiCopilot to use it#13380
iitzIrFan wants to merge 12 commits intokestra-io:developfrom
iitzIrFan:feature/ai-copilot-toon-optimization

Conversation

@iitzIrFan
Copy link
Contributor

✨ Description

feat(ai): implement TOON format for JSON Schema optimization

  • Add ToonUtils utility class for JSON to TOON conversion
  • Integrate TOON conversion in FlowAiCopilot for LLM requests
  • Update FlowYamlBuilder system prompt to indicate TOON format
  • Add comprehensive unit tests (19 tests, all passing)

TOON (Token-Oriented Object Notation) reduces JSON Schema
size by 30-40%, improving LLM response times and reducing token costs.

Implements TOON 2.0 spec with support for:

  • Indentation-based structure
  • Inline primitive arrays
  • Tabular uniform object arrays
  • List-based nested arrays

🔗 Related Issue

Closes: #12433

🛠️ Backend Checklist

  • Code compiles successfully and passes all checks
  • All unit and integration tests pass
  • New unit tests added for ToonUtils and pass (ToonUtilsTest.java)
  • No performance regressions introduced (validate locally and rely on CI)

📝 Additional Notes

Implements TOON encoder to send JSON Schema to the AI Copilot in a compact, indentation-based format to reduce token usage and speed up LLM responses. Integrates ToonUtils.jsonToToon() into the AI flow generation.

  • ToonUtils.java — new TOON encoder
  • FlowAiCopilot.java — uses TOON instead of JSON
  • FlowYamlBuilder.java — system prompt updated to indicate TOON format
  • ToonUtilsTest.java — comprehensive tests (19 tests)

Testing notes (Windows):

  • .\gradlew :core:test --tests ToonUtilsTest :webserver:compileJava

@MilosPaunovic MilosPaunovic added area/backend Needs backend code changes kind/external Pull requests raised by community contributors labels Dec 4, 2025
@iitzIrFan
Copy link
Contributor Author

Any update on this PR? @MilosPaunovic @brian-mulier-p

@brian-mulier-p
Copy link
Member

I'm too busy to properly test this PR rn so it will have to wait a bit sorry

@iitzIrFan
Copy link
Contributor Author

No issues at all, @brian-mulier-p, please take your time reviewing the PR. I also wanted to highlight that, I have added tests for the Toon Utility, which should make the review smoother.

Thanks for your response!

@MilosPaunovic
Copy link
Member

@brian-mulier-p This also needs your eyes, when you get the chance. 🙏🏻

Copy link
Member

@brian-mulier-p brian-mulier-p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • you forgot to update FlowAiCopilot to use it

@iitzIrFan
Copy link
Contributor Author

Will update!

@MilosPaunovic MilosPaunovic moved this from To review to On hold in Pull Requests Mar 6, 2026
@iitzIrFan
Copy link
Contributor Author

@brian-mulier-p , I have updated FlowAiCopilot to use the TOON Utility and made the necessary test updates. The changes are ready for review.

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

Labels

area/backend Needs backend code changes kind/external Pull requests raised by community contributors

Projects

Status: On hold

Development

Successfully merging this pull request may close these issues.

Use TOON to send JSON Schema to LLM in AI Copilot to improve response time

3 participants