cc-haha/release-notes
你的姓名 b0f368ef97 fix(compact): stop re-compaction thrash and post-compact 100% context meter
Two context-management fixes (CLI/sidecar side):

1. Re-compaction loop (方案1+2). Auto-compaction previously only circuit-broke
   on hard failures; a compaction that succeeded but left context still over
   threshold reset the failure counter and re-compacted every turn, burning a
   summary API call each time.
   - autoCompact.ts: isIneffectiveCompaction() — when truePostCompactTokenCount
     is still >= threshold, count it toward the existing circuit breaker instead
     of resetting to 0; query.ts now honours that count on the success path.
   - shouldThrottleAutoCompact() — suppress proactive autocompaction for a few
     turns after a compaction, unless at the hard blocking limit (so we never
     risk prompt-too-long by throttling).

2. Post-compact context meter stuck at ~100% (sessionService.ts). The transcript
   context estimate counted the entire pre-compact history plus the summarization
   call's huge input_tokens, pinning the indicator near full until the next turn.
   Now the estimate is scoped to messages after the latest compact_boundary, with
   a model fallback for the just-compacted/no-new-turn case. Non-compacted
   sessions are unchanged.

Tested:
- bun test src/services/compact/autoCompact.test.ts (12 pass; throttle + ineffective predicates)
- bun test src/server/__tests__/conversations.test.ts -t "context" (6 pass incl. new compact-boundary scoping case)
Not-tested: 4 pre-existing WebSocket runtime-restart integration tests fail in this env (CLI subprocess code 143); unrelated to these changes.
Confidence: high
Scope-risk: moderate
2026-06-09 13:48:40 +08:00
..
2026-04-21 01:02:08 +08:00
2026-04-25 14:02:55 +08:00
2026-05-01 22:13:49 +08:00
2026-05-05 22:47:37 +08:00
2026-05-21 14:28:12 +08:00
2026-05-26 00:52:43 +08:00
2026-06-01 02:30:01 +08:00