improvement: implement TOON format for AI prompts to reduce token consumption#297
Merged
breaking-brake merged 2 commits intomainbreaking-brake/cc-wf-studio:mainfrom Dec 20, 2025
improvement/prompt-structure-optimizationbreaking-brake/cc-wf-studio:improvement/prompt-structure-optimizationCopy head branch name to clipboard
Merged
improvement: implement TOON format for AI prompts to reduce token consumption#297breaking-brake merged 2 commits intomainbreaking-brake/cc-wf-studio:mainfrom improvement/prompt-structure-optimizationbreaking-brake/cc-wf-studio:improvement/prompt-structure-optimizationCopy head branch name to clipboard
breaking-brake merged 2 commits intomainbreaking-brake/cc-wf-studio:mainfrom
improvement/prompt-structure-optimizationbreaking-brake/cc-wf-studio:improvement/prompt-structure-optimizationCopy head branch name to clipboard
Conversation
- Install @toon-format/toon official library for TOON encoding - Add RefinementPromptBuilder with TOON format support - Add locale support (responseLocale) to prompts for multilingual responses - Simplify prompt construction by fixing format to TOON (7.3% token reduction) - Add promptFormat to metrics collection for monitoring - Remove promptFormat configuration (always use TOON) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add WorkflowNamePromptBuilder with TOON format support - Add SlackDescriptionPromptBuilder with TOON format support - Simplify by using responseLocale only (remove LANGUAGE_INSTRUCTIONS) - Add promptFormat to logs for monitoring
Merged
github-actions Bot
added a commit
that referenced
this pull request
Dec 20, 2025
## [3.8.4](v3.8.3...v3.8.4) (2025-12-20) ### Improvements * add tool execution loading animation in AI chat ([#298](#298)) ([5615efe](5615efe)) * AI editing chat enhancements with allowed tools UI and strict tool restrictions ([#299](#299)) ([d72f241](d72f241)) * implement TOON format for AI prompts to reduce token consumption ([#297](#297)) ([64fe228](64fe228))
Contributor
|
🎉 This PR is included in version 3.8.4 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
AI prompt construction for workflow operations currently uses freetext format with markdown sections, which consumes unnecessary tokens due to:
Current Behavior
**,-, numbered lists) add overheadExpected Behavior
Solution
Implemented TOON (Token-Oriented Object Notation) format for all AI prompts using the official
@toon-format/toonlibrary:Key Changes
responseLocalefield for multilingual responsesTOON Format Benefits
nodes[3]: id,type,name(CSV-style)Changes
New Files
File:
src/extension/services/refinement-prompt-builder.ts(118 lines)@toon-format/toonofficial libraryFile:
src/extension/services/workflow-name-prompt-builder.ts(41 lines)File:
src/extension/services/slack-description-prompt-builder.ts(40 lines)Modified Files
File:
src/extension/services/refinement-service.tsRefinementPromptBuilderpromptFormat: 'toon'to all logs and metricsFile:
src/extension/commands/workflow-name-generation.tsWorkflowNamePromptBuilderpromptFormatloggingFile:
src/extension/commands/slack-description-generation.tsSlackDescriptionPromptBuilderpromptFormatloggingFile:
src/extension/services/ai-metrics-service.tsgetConfiguredPromptFormat()(always use TOON)PromptFormatimportFile:
src/shared/types/ai-metrics.tsPromptFormattype:'freetext' | 'json' | 'toon'promptFormatfield toAIGenerationMetricsinterfaceFile:
package.json@toon-format/toon: ^1.4.0cc-wf-studio.ai.promptFormatconfiguration (TOON is now always used)cc-wf-studio.ai.collectMetricsdescriptionImpact
Token Reduction
Cost Savings (Estimated)
User Experience
responseLocaleCode Quality
PromptBuilderBase,toon-encoder.ts)Testing
npm run format,npm run lint,npm run check)npm run build)Notes
Why 7.3% instead of expected 28-35%?
The original plan estimated 28-35% reduction for fixed text portions only. In practice:
currentWorkflow,conversationHistory): ~56% of total promptThe 7.3% overall reduction is realistic given the large proportion of variable JSON data.
Design Simplifications Made
LANGUAGE_INSTRUCTIONS: UsingresponseLocaleonlytoon-encoder.ts)Future Optimization Opportunities