anomalyco / anomalyco/opencode

[FEATURE] Add auto-compact threshold for long sessions

Open
#40,113 2 comments 0 reactions 1 assignee View on GitHub

@nexxeln is already working on this.

Since Aug 2, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Problem

Currently opencode TUI has no automatic context compression. After long sessions, context grows uncontrollably (observed 160K+ tokens), forcing manual compact command.

Proposed Solution

Add configuration for automatic compression:

{
  "session": {
    "maxContextTokens": 120000,
    "autoCompactThreshold": 0.75
  }
}

When context reaches 75% of max, auto-trigger compact to ~40-50% threshold.

Why

  • Openclaw has similar auto-compact feature (works well)
  • Qwen3.5-122B has 128K context limit, 75% (96K) is safe operational threshold
  • Current manual workflow is error-prone for long debugging sessions

Impact

  • Preserve session continuity without manual intervention
  • Prevent GPU memory overload during long tasks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.