Session compaction OOMs and never completes, leaving the session permanently unresumable (heap exhaustion at default ~4.3 GB cap)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- javascript, node.js
- 領域
- cli, performance
研究方向
該 issue 沒有指出原始檔案或測試。首先在大型工作階段中使用 --resume 重現問題,並使用 --report-on-fatalerror 報告追蹤 session.compaction_start 貫穿壓縮程序;完成的標準是壓縮失敗受到限制且可採取行動,同時工作階段保持可復原,而不是反覆 OOM。
由索引模型根據 Issue 內容生成。
描述
Describe the bug
A session that reaches the context-compaction threshold enters an unrecoverable crash loop: session.compaction_start is emitted, compaction never completes, and the process dies with Allocation failed - JavaScript heap out of memory. Every subsequent --resume re-enters the same failing compaction and OOMs again, so the session is permanently unopenable.
The machine had ~56 GB of 67 GB RAM free at every crash. This is V8 old-space exhaustion against the default ~4.3 GB cap, not system memory pressure.
Evidence
Four consecutive --report-on-fatalerror diagnostic reports, all trigger: OOMError, event: Allocation failed - JavaScript heap out of memory:
| Crash (UTC) | JS heap used/limit | old_space available | RSS | CPU consumed |
|---|---|---|---|---|
| 11:58:49 | 4.06 / 4.30 GB | 156,944 B | 4.94 GB | 590 s |
| 12:31:50 | 4.03 / 4.30 GB | 108,768 B | 5.57 GB | 964 s |
| 12:36:26 | 4.15 / 4.30 GB | 242,800 B | 6.46 GB | 466 s |
| 12:45:32 | 4.01 / 4.30 GB | 209,008 B | 6.06 GB | 602 s |
workers: 0 and no child-process handles in every report — the growth is in the main isolate. RSS exceeding heap by 1–2 GB indicates significant native allocation on top. CPU consumption of 265–286% is consistent with GC thrash.
Root cause signal
The session event log contains four session.compaction_start events and no corresponding completion event for any of them. Each start aligns with a crash, and the token count increases across attempts — compaction never reclaims anything:
session.compaction_start |
trigger | currentTokens |
|---|---|---|
| 10:31:24.938 | memory_pressure |
125,865 |
| 10:36:07.701 | memory_pressure |
135,928 |
| 10:45:01.851 | threshold (tokenLimit 200,000) |
160,996 |
| 10:45:25.351 | memory_pressure |
161,730 |
The last two are 24 seconds apart: a threshold-triggered compaction started, did not finish, a new assistant turn started regardless, and a second compaction fired under memory pressure — then the heap was exhausted. So a failed compaction does not halt or retry-with-backoff; the turn proceeds and the conversation keeps growing, guaranteeing the next attempt is strictly larger and fails sooner.
Secondary symptom (likely not the cause)
Immediately before each OOM the log floods with:
[WARNING] [rust:session_bindings::api_session_event_stream] Session event stream lagged while flushing {"skipped":<N>}
[WARNING] [rust:session_bindings::api_session_event_stream] Session event stream lagged; recovering from the registry snapshot {"skipped":592}
[WARNING] [rust:session_bindings::api_memory_pressure] Memory pressure persists after GC - triggering emergency compaction
Worth noting: the reported skipped counts exceed the total number of events the session ever produced (592 skipped vs. 437 total events, 1.6 MB on disk, zero duplicate event IDs). So this is the event consumer starving while the main thread is blocked in the failing compaction and then re-syncing from the registry snapshot — a symptom, not the driver. The underlying session data is small; 437 events and 1.6 MB should not require 4 GB of heap to compact.
Affected version
- Copilot CLI 1.0.83
- Bundled Node v24.20.0, V8 13.6.233.17-node.53
- Linux, glibc 2.39, x86_64, 32 CPUs, 67 GB RAM
- Launched as:
copilot --no-warnings --report-on-fatalerror --optimize-for-size --expose-gc(noNODE_OPTIONSset, so the default old-space limit applied)
Steps to reproduce the behavior
- Run a long session that accumulates context toward the compaction threshold (this one reached ~161k tokens against a 200k limit, over roughly one hour, with many tool calls and large tool outputs).
- Let automatic compaction trigger (
trigger: threshold, ormemory_pressure). - Observe the process OOM before compaction completes.
--resumethe session. It re-enters compaction and OOMs again, reproducibly — four for four here, surviving between 3m46s and ~10 minutes each time.
I do not have a minimal reproducer; it appears to require a session large enough to trigger compaction. Happy to supply further redacted detail from the diagnostic reports on request.
Expected behavior
- Compaction should complete within a bounded memory budget, and should not require materializing the whole conversation such that a ~1.6 MB session exhausts a 4 GB heap.
- A failed compaction should surface an actionable error and stop the turn, rather than allowing the turn to proceed and the context to grow further.
- Repeated
memory_pressurecompaction attempts should back off instead of retrying into a guaranteed OOM. - A session that cannot be compacted should still be openable in a degraded/read-only mode so the work is recoverable, instead of becoming permanently unloadable.
Additional context
- Raising the ceiling via
NODE_OPTIONS="--max-old-space-size=12288"is a plausible workaround, but the fact that the token count grows on every attempt suggests a larger heap may only delay the failure rather than let compaction converge. - The default heap cap may be worth revisiting for the bundled runtime: the process dies at ~4.3 GB on a host with 56 GB free.
- Diagnostic reports are written to the current working directory as
report.<date>.<time>.<pid>.0.001.json. It would help to place these under the CLI state directory instead, or document them, since they land inside whatever repository the user is working in and are easy to commit accidentally.
Details deliberately redacted: session content, file paths, repository and account identifiers.
- 主要語言
- Shell
- 星號
- 11.2k
- 分支
- 1.9k
- 平均合併
- 17 小時 6 分鐘
- 30 天內合併 PR
- 5
環境準備
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
github/copilot-cli 的其他 Issue
-
triage
難度 1/5 1 小時以內 新手友好度 88/100
github/copilot-cli#4963 · 1 則留言 ·
維護者通常 1 天內回覆
-
triage
難度 2/5 1-3 小時 新手友好度 75/100
github/copilot-cli#4932 ·
維護者通常 1 天內回覆
-
triage
難度 2/5 1-3 小時 新手友好度 78/100
github/copilot-cli#4909 ·
維護者通常 1 天內回覆
-
triage
難度 2/5 1-3 小時 新手友好度 76/100
github/copilot-cli#4906 ·
維護者通常 1 天內回覆
-
triage
難度 2/5 1-3 小時 新手友好度 72/100
github/copilot-cli#4848 ·
維護者通常 1 天內回覆
查看 github/copilot-cli 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 88/100
-
backlog bug
難度 2/5 1-3 小時 新手友好度 86/100
WLAN-Pi/wlanpi-profiler#306 ·
維護者通常 1 天內回覆
-
area: backend good first issue priority: P3 - low size: S type: bug
難度 2/5 1-3 小時 新手友好度 78/100
Mizithra/ActiveTerrain#31 ·
-
難度 2/5 1-3 小時 新手友好度 68/100
obra/superpowers#2422 ·
維護者通常 6 天內回覆
-
難度 2/5 1-3 小時 新手友好度 88/100
ComplianceAsCode/content#15152 ·
維護者通常 3 天內回覆