Skip to content

Conversation

@verrerie
Copy link

Summary

Implements configurable context compaction threshold as requested in #11314.

Changes

  • Added compaction configuration schema to opencode.json with threshold, strategy, preserveRecentMessages, preserveSystemPrompt.
  • Added support for per-model compaction configuration overrides.
  • Updated SessionCompaction.isOverflow to respect the configured threshold (global or model-specific).
  • Added unit tests for threshold logic.

Configuration Example

{
  "compaction": {
    "threshold": 0.40
  },
  "provider": {
    "google": {
      "models": {
        "gemini-1.5-pro": {
          "compaction": {
            "threshold": 0.30
          }
        }
      }
    }
  }
}

Fixes #11314

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found several related PRs that may be addressing similar functionality:

Potential Related PRs:

  1. PR fix(opencode): prevent context overflow during compaction #11453 - "fix(opencode): prevent context overflow during compaction"

    • Very recent and directly related to context overflow prevention during compaction
  2. PR feat(session): add custom compaction thresholds along with prevention of continuous compaction #10123 - "feat(session): add custom compaction thresholds along with prevention of continuous compaction"

  3. PR feat(opencode): add context overflow prevention with configurable thresholds #8810 - "feat(opencode): add context overflow prevention with configurable thresholds"

    • Previous work on configurable context overflow thresholds
  4. PR feat(opencode): trigger compaction earlier and add multi-file read #9656 - "feat(opencode): trigger compaction earlier and add multi-file read"

    • Related to compaction triggering logic

These PRs appear to be in the same feature area (configurable compaction thresholds and context overflow prevention). PR #10123 in particular seems to have similar functionality. I'd recommend checking if PR #11467 is an enhancement/update to the work already done in #10123, or if they're duplicates.

@verrerie verrerie marked this pull request as draft January 31, 2026 13:58
@verrerie verrerie closed this Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Configurable Context Compaction Threshold

1 participant