How does opencode's auto-compact actually work — trigger threshold and config surface? #27
Notifications
Due Date
No due date set.
Blocks
Reference: haylan/LLM-Server#27
Reference in New Issue
Block a user
Part of #26
Question
opencode has an "auto-compact" behavior (summarizing/truncating older
messages when context fills). What, precisely, does it use to decide when
to trigger — a hardcoded percentage of `limit.context`? A separate config
key? Does it exist at all for the `@ai-sdk/openai-compatible` provider
path (the one this repo's `opencode-cli-setup.md` documents for
llama.cpp/litellm-style backends), or only for opencode's built-in/hosted
providers?
Specifically resolve:
(global `opencode.json`, per-provider, or per-model under `models.`).
a reasoning/thinking budget (relevant here — Qwen3.8 spends
`reasoning_content` tokens before `content`, see `litellm-config.yaml`'s
`max_tokens` comment on this repo's `qwen3.8-27b-local`).
behavior.
`docs/research/opencode-cli-setup.md` is dated 2026-08-24) — confirm
current docs/changelog, don't just trust that file.
Primary sources: https://opencode.ai/docs/ (compaction/context-management
section, wherever it currently lives — may be under a "context" or
"sessions" page, not obviously named), the opencode GitHub repo
(`anomalyco/opencode`) issues/source if docs are silent.
Researched OpenCode's auto-compact mechanism directly from source (anomalyco/opencode @ b578b72, v1.18.27, cloned 2026-09-03) plus live docs.opencode.ai fetches.
Key findings — full writeup at docs/research/opencode-auto-compact.md on branch research/opencode-auto-compact:
Confidence levels and full citations are in the doc.