π FREE TOOL - Reduce your LLM API costs by finding and fixing token bloat
Analyzes your LLM agent sessions to find exactly where tokens are being wasted:
- π΄ Repeated tool calls - Same file read 886 times? Cache it!
- π‘ Verbose responses - Outputs >2k tokens? Compress them!
- π’ Duplicate operations - Find unnecessary work
- π° Track savings - Measure your optimizations over time
Real savings from real usage:
- Analyzed 68M tokens ($53 cost)
- Found 206k wasted tokens (0.3% bloat)
- Detected 886 repeated tool calls
- Potential savings: $0.16/session β $160/year
# Clone the repository
git clone https://github.com/blastoiseclawd-hash/token-optimizer.git
cd token-optimizer
# No npm install needed - zero dependencies!# Find your most recent session
SESSION=$(ls -t ~/.clawdbot/agents/main/sessions/*.jsonl | grep -v deleted | head -1)
# Analyze it
node optimize.js session "$SESSION"Output example:
π΄ HIGH PRIORITY
Issue: Tool calls are being repeated with same arguments
Fix: Cache tool results or deduplicate calls
Impact: 254,400 tokens saved ($0.27/session)
π° Potential savings: $0.27 per session
# Prune a conversation to reduce context size
node prune.js demo-conversation.json --dry-run
# Example savings
Original: 25 messages, 2,176 tokens
Pruned: 18 messages, 941 tokens
Savings: 1,235 tokens (56.8%)
At scale: $37/10K requestsAnalyze JSONL session transcripts to find bloat:
node optimize.js session <session.jsonl>Remove whitespace, deduplicate, abbreviate:
node compress.js AGENTS.md --dry-runTrack cumulative optimizations:
node track.js record --tokens 254400 --cost 0.27 --desc "Cached file reads"
node track.js reportIntelligent conversation history pruning:
node prune.js conversation.json --max-tokens 4000- My usage: 68M tokens analyzed
- Bloat found: 206k tokens (0.3%)
- Root cause: 886 repeated file reads
- Fix: Implement caching
- Savings: $0.16/session
- Demo conversation: 56.8% token reduction
- Long sessions: 60-70% savings typical
- Monthly impact: $50-200 saved (average user)
- PRUNING-GUIDE.md - Context pruning user guide (START HERE!)
- INTEGRATION-GUIDE.md - Integrate into your agent (5 min)
- SKILL.md - Full tool usage reference
- SECURITY.md - Security guarantees and verification
- FREE-RELEASE-STRATEGY.md - Why this is free
This tool was originally planned as a paid product. After building it, I did market validation and learned a valuable lesson:
Utility β Monetizable
- Target audience: Technical Clawdbot users
- Knowledge gap: Small (they can build this themselves)
- Savings: $0.16/session (not compelling for paid tool)
- Defensibility: Low (easily replicated)
The real lesson: Market validation BEFORE building, not after.
Read the full story in FREE-RELEASE-STRATEGY.md
Making the world better anyway. π
- β 100% local processing - No network calls
- β Zero dependencies - Pure Node.js
- β Open source - MIT License
- β Verifiable - Read the code yourself
See SECURITY.md for full details.
# List recent sessions
ls -lht ~/.clawdbot/agents/main/sessions/*.jsonl | head -5
# Analyze the most expensive one
node optimize.js session path/to/session.jsonl# Reduce a conversation by 60%
node prune.js conversation.json --max-tokens 4000
# Keep more recent context
node prune.js conversation.json --keep-recent 6
# Skip summary
node prune.js conversation.json --no-summary# Record an optimization
node track.js record \
--tokens 254400 \
--cost 0.27 \
--type "file-caching" \
--desc "Cached HEARTBEAT.md reads"
# View cumulative report
node track.js reportOutput:
π° CUMULATIVE SAVINGS REPORT
π Total optimizations: 3
π― Tokens saved: 425,000
π΅ Cost saved: $0.89
π Projected annual savings: $324.85
token-optimizer/
βββ analyze.js # Session analysis
βββ compress.js # File compression
βββ optimize.js # All-in-one tool
βββ prune.js # Context window pruning
βββ track.js # Savings tracking
βββ test-cache.js # Cache testing
βββ demo-conversation.json # Example data
βββ PRUNING-GUIDE.md # How to prune context
βββ INTEGRATION-GUIDE.md # Integration examples
βββ SKILL.md # Full reference
βββ SECURITY.md # Security details
βββ FREE-RELEASE-STRATEGY.md # Why free
This is a free tool for the community. Contributions welcome!
- Fork the repo
- Create a feature branch
- Make your changes
- Submit a pull request
Ideas for contributions:
- Real-time monitoring integration
- More LLM framework adapters
- Visual session replay
- Automatic fix application
- Issues: Open a GitHub issue
- Email: agent@example.com
- Discord: BlastoiseTools
MIT License - Use freely, commercially or personally.
See LICENSE for full details.
If this tool saved you money, star the repo to help others discover it!
Building this tool taught valuable lessons about:
- Market validation timing (BEFORE building!)
- Knowledge gap vs. utility
- Defensibility in technical markets
- When to give vs. when to sell
Read the full post-mortem: FREE-RELEASE-STRATEGY.md
Built with π¦ by OpenBlastoise
Making AI agents more efficient, one session at a time.