compaction: buffer of 180,904 reduces 200k window ceiling to just 15k tokens
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- cli
Hướng nghiên cứu
Đọc packages/core/src/session/compaction.ts và hàm calculateCeiling. Hiểu cách buffer được trừ khỏi giới hạn đầu vào cửa sổ. Triển khai một clamp để buffer không thể giảm trần xuống dưới một sàn hợp lý (vd. RESERVE_SHARE), hoặc cập nhật tài liệu. Xong nghĩa là một buffer lớn không còn làm sụp đổ ngưỡng kích hoạt xuống ~15k tokens.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Automatic context compression triggers far too early (after ~15k tokens) despite a 200k token context window, because the configured compaction.buffer is subtracted directly from the model's input limit, leaving only 195,904 − 180,904 = 15,000 tokens of headroom before compaction fires.
Environment
- opencode version: 2.1.3
- OS: Darwin 27.0.0 (darwin arm64)
- Terminal: Unavailable (terminal environment variables not set)
- Shell: /bin/zsh
- Install/channel: latest
- Active plugins: -opencode.browser, /Users/thtesche/.config/openchamber/run/instances/52345/agent-tool/openchamber-agent-tool, @openchamber/opencode-claude@^1
- Active model:
strata/qwen3.8-flash-next-q2_0(context: 200,000 / input: 195,904 / output: 4,096) - User config:
compaction: { auto: true, buffer: 180904 }
Reproduction
- Set
compaction.bufferto a large value close to the model's input limit (e.g.180904of195904). - Start a session and exchange enough messages that the measured context passes ~15k tokens.
- Observe automatic compaction firing on nearly every turn, well before the 200k window is approached.
Expected Behavior
With a 200k context window and buffer unset, automatic compaction should not fire until roughly 85% of the window is used (~166k tokens). A large buffer should not collapse the ceiling to ~15k tokens.
Actual Behavior
The ceiling is calculated as window - buffer = 15,000 tokens, so due() returns true as soon as estimateContext(context) >= 15,000. Compaction fires after only a few exchanges, repeatedly rewriting history and discarding prompt-cache benefits.
Root Cause
calculateCeiling in packages/core/src/session/compaction.ts (introduced 2026-10-23 in commit 33726e8, PR #58313):
const calculateCeiling = (limit, buffer) => {
const window = limit.input || limit.context // 195,904
if (buffer !== undefined && buffer < window) // 180,904 < 195,904 → true
return window - buffer // 195,904 − 180,904 = 15,000
return window - Math.max(Math.floor(window * RESERVE_SHARE), RESERVE_MIN)
}
When buffer is set but still smaller than window, it is subtracted in full. The fallback to RESERVE_SHARE (15%) only applies when buffer >= window or buffer is unset.
The same day's commit added a guard ("ignore a compaction buffer that leaves the model no room"), but it only ignores buffers >= window. A buffer of 180,904 against an input limit of 195,904 still passes the buffer < window check, so the 15k ceiling stands.
Additional Context
- Evidence from
opencode.db: two local sessions exist, both measured well under the current 15k ceiling; the active strata/qwen3.8 session showsinput 707 / output 8847 / reasoning 3165 / cache read 245141 / cache write 127909— cache-heavy, soestimateContextclimbs quickly. - The
eventtable inopencode.dbis empty; compaction events are not persisted there, so the DB alone cannot confirm trigger counts. The code path is sufficient evidence. - This is not issue #50474 (auto-compaction loop on provider-reported overflow). This is a config/ceiling interaction: a user-set buffer collapses the trigger threshold.
- Suggested fix: validate
compaction.bufferso it cannot reduce the ceiling below a sane floor (e.g.RESERVE_SHAREof the window), or document thatbuffervalues close toinputwill cause near-immediate compaction.
- Ngôn ngữ chính
- TypeScript
- Star
- 221k
- Fork
- 29.6k
- Merge trung bình
- 4 giờ 35 phút
- Pull request đã merge (30 ngày)
- 521
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của anomalyco/opencode
-
triaging
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
anomalyco/opencode#58821 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
anomalyco/opencode#58725 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Snapshot capture failure (EPERM spawning git) fails the whole step despite the best-effort contractCó thể đã có người làm @Dopetaiga đã nhận 1 ngày trước. Đang mởreproduced
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
anomalyco/opencode#58685 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
tui: PHP code blocks without `<?php` are not syntax highlightedCó thể đã có người làm @SwastikTripathi đã nhận 1 ngày trước. Đang mởreproduced
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
anomalyco/opencode#58664 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
patch: moving an executable script removes its executable bitCó thể đã có người làm @chenyb999-zhcn đã nhận 1 ngày trước. Đang mởreproduced
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
anomalyco/opencode#58651 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của anomalyco/opencode
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
microsoft/playwright#43640 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
grasshopper-protocol/grsshppr#172 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Tencent/teamai-cli#1397 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
DouyinFE/semi-design#3641 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày