## Summary Implement Phase 2 of Compact Mode: Compression engine for actual token reduction. ## Background Phase 1 provides UI compression (display only). Phase 2 adds actual token reduction sent to LLM APIs. ## Phase 2 Scope (4 weeks) ### Compression Technologies (Vendor-Agnostic Only) | Technology | Token Reduction | Implementation | |------------|-----------------|----------------| | **LLMLingua-2** | Up to 20x | Python sidecar | | **Conversation Pruning** | 30-50% | Native | | **Tool Output Truncation** | Variable | Native | | **TOON Format** | 35-50% vs JSON | Native | ### Quality vs Compression Trade-off | Ratio | Quality Retention | Risk | |-------|-------------------|------| | 2x-5x | 95-98% | ✅ Recommended | | 5x-10x | 90-95% | ⚠️ Caution | | 10x-20x | 85-95% | ⚠️ Task-dependent | ### Deliverables - [ ] LLMLingua-2 Python sidecar integration - [ ] Sidecar lifecycle management (lazy loading, timeout cleanup) - [ ] Conversation pruning logic (keep recent N, compress older) - [ ] TOON format serializer for structured data - [ ] Compression threshold configuration - [ ] Quality preservation settings (protect entities, numbers) - [ ] Compression metrics display (tokens saved) ### Technical Notes - **LLM Understanding Impact**: 2-5% at recommended settings - **Vendor Agnostic**: ✅ All techniques work with any LLM - **Excluded**: Anthropic Token-Efficient Tools (Claude-only) - **Excluded**: Provider-specific Prompt Caching (non-interoperable) ### Best Practices 1. Preserve named entities and numbers explicitly 2. Use extractive (LLMLingua-2) over abstractive methods 3. Never compress recent 3 messages 4. Set maximum compression threshold at 80% ### Files to Create/Modify - `packages/opencode/script/llmlingua-sidecar.py` - Python compression service - `packages/opencode/src/session/compression.ts` - Compression client - `packages/opencode/src/session/compaction.ts` - Enhance existing pruning ## Dependencies - Requires: #9017 (Phase 1) ## Success Criteria - [ ] 50-70% token reduction achieved - [ ] Quality retention >95% on standard tasks - [ ] Sidecar starts/stops correctly - [ ] Metrics displayed in TUI ## Related - Phase 1: #9017 - Phase 3: #TBD (Intelligence Layer) --- *Generated by Trinitas Full Mode Analysis*
Activity
github-actions commentedon Jan 17, 2026
This issue might be a duplicate of or closely related to existing issues. Please check:
Feel free to ignore if none of these address your specific implementation approach for Phase 2.
rekram1-node commentedon Jan 17, 2026
closing - spam