feat(tui): Compact Mode Phase 2 - Compression Engine Integration #6557

Closed
opened 2026-02-16 18:04:35 -05:00 by yindo · 2 comments
Owner

Originally created by @apto-as on GitHub (Jan 16, 2026).

Originally assigned to: @thdxr on GitHub.

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


Generated by Trinitas Full Mode Analysis

Originally created by @apto-as on GitHub (Jan 16, 2026). Originally assigned to: @thdxr on GitHub. ## 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*
yindo closed this issue 2026-02-16 18:04:35 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 16, 2026):

This issue might be a duplicate of or closely related to existing issues. Please check:

  • #6034: [FEATURE]: Prompt Compression - References LLMLingua for token compression
  • #7459: [FEATURE]: implement smart pruning - Addresses intelligent conversation pruning mechanisms
  • #4659: [FEATURE] Sliding window context management for long-running sessions - Comprehensive approach to context management with preservation strategies

Feel free to ignore if none of these address your specific implementation approach for Phase 2.

@github-actions[bot] commented on GitHub (Jan 16, 2026): This issue might be a duplicate of or closely related to existing issues. Please check: - #6034: [FEATURE]: Prompt Compression - References LLMLingua for token compression - #7459: [FEATURE]: implement smart pruning - Addresses intelligent conversation pruning mechanisms - #4659: [FEATURE] Sliding window context management for long-running sessions - Comprehensive approach to context management with preservation strategies Feel free to ignore if none of these address your specific implementation approach for Phase 2.
Author
Owner

@rekram1-node commented on GitHub (Jan 16, 2026):

closing - spam

@rekram1-node commented on GitHub (Jan 16, 2026): closing - spam
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6557