GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing github.com — feat(compaction): Hybrid compaction pipeline with deterministic extraction + LLM by thijs-hakkenberg · Pull Request #7104 · anomalyco/opencode ConversationDescriptionThis PR introduces a novel hybrid compaction approach that significantly improves session continuation quality by combining deterministic extraction with targeted LLM semantic analysis. ProblemThe current compaction implementation uses a generic freeform LLM prompt that often loses critical details:
SolutionA hybrid pipeline that runs sequentially for optimal token efficiency: ┌─────────────────────────────────────────────────────────────┐ Key Features
New Filespackages/opencode/src/session/compaction/ packages/opencode/test/session/ Configuration{ Example OutputSession CompactionGenerated: 2025-01-06T12:00:00.000Z Session IntentImplement user authentication with JWT tokens ArtifactsFiles Read
Files Modified
Files Created
Tool Usage Summary
Decisions Made
Current StateLogin endpoint complete, working on refresh token implementation Pending Tasks
Key ContextExpress.js backend with PostgreSQL. User requested no external auth providers. Compression: 94.2% (50000 → 2900 tokens) Testing
Breaking Changes None. Hybrid compaction is additive and enabled by default. Can be disabled via compaction.hybrid.enabled: false. To run tests locally:
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions- Add CompactionTemplate schema with Zod validation - Define deterministic sections: artifacts, tool_calls, errors - Define LLM sections: session_intent, current_state, decisions, pending_tasks, key_context - Add optional agent_context for preserving agent personality - Add compression metrics tracking - Include comprehensive test suite for schema validation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> … tools - Add extractFiles() to extract file operations from Read/Edit/Write tools - Add extractErrors() with pattern matching for common error types - Add extractToolCalls() to consolidate tool usage statistics - Add condenseContext() to create LLM-friendly summary - Track error resolution status based on success indicators - Comprehensive test coverage for all extractors 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> - Add buildPrompt() to create efficient extraction prompt - Add messagesToRecentContext() to convert messages to text with limits - Add parseResponse() to handle JSON extraction with fallbacks - Add extractAgentContext() to preserve agent personality/constraints - Define structured output schema for generateObject integration - Comprehensive test coverage including edge cases 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> - Add scoreCompleteness() to validate critical sections are filled - Add scoreInformationRetention() to check file path preservation - Add getIssues() to identify specific quality problems - Add scoreCompaction() combining all quality checks with threshold - Weighted scoring: 60% completeness, 40% retention - Comprehensive test coverage for scoring edge cases 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Implements HybridCompactionPipeline namespace with: - runDeterministicPhase(): orchestrates extractors, creates condensed context - estimateTokens(): estimates token count from messages - assembleTemplate(): combines deterministic + LLM results - templateToText(): converts template to human-readable format - buildLLMPrompt(): constructs prompt for LLM extraction - validateQuality(): runs quality validation with threshold Key design: Sequential execution where deterministic phase runs FIRST, creating condensed context that reduces token usage for LLM phase. Tests added for all pipeline functions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Integration changes: - compaction.ts: Use HybridCompactionPipeline when enabled (default: true) - Phase 1: Deterministic extraction (files, errors, tool calls) - Phase 2: Build condensed LLM prompt (reduces token usage) - Phase 3: Run LLM extraction via processor - Phase 4: Optional quality validation with threshold - Falls back to legacy compaction if hybrid disabled - config.ts: Add hybrid compaction config options: - enabled: Enable/disable hybrid pipeline (default: true) - preserve_agent_context: Preserve agent context (default: true) - quality_threshold: Optional quality gate (0-1) - compaction.txt: Update prompt for structured JSON extraction - index.ts: Re-export all compaction modules Key design: Sequential execution - deterministic extraction runs FIRST, creating condensed context that significantly reduces LLM token usage. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Fix TypeError detection by: - Reordering patterns: specific error types (TypeError, ReferenceError, etc.) first - Capturing the full error including the type name in the message - Using negative lookbehind to prevent general Error pattern from matching specific types All 61 tests now pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Add a new CLI command `opencode benchmark` to compare hybrid vs legacy compaction methods. Features include: - BenchmarkMetrics: Type definitions for metrics collection - BenchmarkRunner: Orchestrates benchmark runs with both methods - RefactorTask: Complex multi-file refactoring task for testing - CompactionJudge: LLM-based evaluation of compaction quality - CLI command with options for task selection, model, and judge Metrics captured per compaction: - Input/output tokens and total - Timing (duration_ms) - Compression ratio - Compaction output text (for LLM judgment) Results are saved to JSON files for analysis. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Add run-benchmark.ts for running benchmarks without full CLI dependencies. Include real benchmark results comparing hybrid vs legacy compaction: Results with xiaomi/mimo-v2-flash:free: - Hybrid: 3,327ms, 979 tokens, 55.1% compression - Legacy: 5,978ms, 1,389 tokens, -2.6% compression - Token savings: 29.5% - Time savings: 44.4% - Winner: HYBRID 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This was referenced
opencode-agent
Bot
force-pushed
the
dev
branch
from
00637c0 to
71e0ba2
Compare
thdxr
force-pushed
the
dev
branch
3 times, most recently
from
f1ae801 to
08fa7f7
Compare
3 tasks done
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersNo reviewsUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. 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. | |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |