Skip to content

Conversation

@tobiastornros
Copy link

@tobiastornros tobiastornros commented Feb 3, 2026

Ever noticed how Opus gets kinda dumb around 50-60% context? Yeah, me too. Built this to escape the dumbzone.

Adds compaction settings at both global and per-model levels:

  • threshold (1-100) - trigger compaction earlier, before models go stupid
  • model - use a cheaper model for compaction (why waste Opus on summaries?)

Global config:

{
  "compaction": {
    "threshold": 80,
    "model": "anthropic/claude-haiku-5-20260205"
  }
}

Per-model config:

{
  "provider": {
    "anthropic": {
      "models": {
        "claude-opus-4-20250514": {
          "compaction_threshold": 50,
          "compaction_model": "zhipu/glm-4-plus"
        }
      }
    }
  }
}

Per-model overrides global. Default is 100 (current behavior).

Closes #11930
Relates to #11314, #8140, #10017, #8629

…model)

Add compaction settings at both global and per-model levels:
- threshold: trigger compaction at a percentage of context (1-100, default: 100)
- model: use a different model for compaction summaries

This allows users to:
- Trigger compaction earlier for models that degrade at lower context usage
- Use cheaper/faster models for compaction to save costs

Closes anomalyco#11930
Relates to anomalyco#11314, anomalyco#8140, anomalyco#10017, anomalyco#8629
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

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

Related PRs Found

Potential duplicates/related work:

  1. 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

    • Directly related: adds custom compaction thresholds (similar feature)
  2. feat(opencode): add context overflow prevention with configurable thresholds #8810 - feat(opencode): add context overflow prevention with configurable thresholds

    • Overlaps on configurable thresholds for context management
  3. feat(opencode): trigger compaction earlier and add multi-file read #9656 - feat(opencode): trigger compaction earlier and add multi-file read

  4. fix(opencode): accumulate step tokens for compaction #10215 - fix(opencode): accumulate step tokens for compaction

    • Related: compaction token handling
  5. fix(opencode): prevent context overflow during compaction #11453 - fix(opencode): prevent context overflow during compaction

    • Related: context management during compaction

These PRs suggest there's been ongoing work on compaction and context threshold features. PR #10123 appears most similar, implementing custom compaction thresholds. You may want to check if #11931 supersedes or builds upon any of these, particularly #10123.

@tobiastornros
Copy link
Author

tobiastornros commented Feb 3, 2026

Future idea: we could add compaction_max_tokens on model level too, an absolute token cap regardless of percentage. Useful for cost control or latency-sensitive setups. Kept it simple for now, can extend later.

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: Configurable compaction threshold and model (global + per-model)

1 participant