Repository navigation
Replies: 3 comments 1 reply
|
Verified against Problem 2 — the replay is deliberate, so "stop replaying" is not the fix.
What survives that constraint is bounding the input rather than moving it. The replay is useful only up to the first node you prune, so a bound that trims the bulkiest tool results inside the same prefix keeps the system head and the message order, and costs one cold prefill from that node onward. That is your proposal 3 — and it is worth pricing explicitly, because the alternative (re-route the auxiliary call) trades a different cost. Problem 1 — the ~32% is a declared property of the estimator, not a defect in your route.
Your Your "additional observations". The zstd one is confirmed with a sharper consequence: On the recovery path. I can contribute a plugin for the bounded-input half, with the goal that recovery compaction fits the window exactly when the session is otherwise unrecoverable. It would sit on the |
|
Thanks for the detailed report — the three-mechanism breakdown is accurate, and one of them is a missing capability rather than a wrong number, which is the part a deployment can close from outside.
npm install @argszero/dsh-overflow-recoveryIt is a Cordis plugin mounted through Where it lines up with your three findings:
The drop is one durable pair in the shape the shipped producers append — a It is honestly lossy, and the notice it leaves in the surface says so: the content is dropped, not summarized, and the model is told to ask rather than guess. Versions: it builds and passes its suite against |
跟进:完整复现 + 根因定位 + 一份可验证的修复我们在本机(Windows 桌面版,
复现(原样贴出日志字段)
修复后的实测效果
验证矩阵(两条分支上跑的)
需要的话我可以把这两条分支整理成按你们流程走的最小补丁(拆成可单独评审的 commit 序列,附上上述验证脚本的复跑方式)。 |
Uh oh!
There was an error while loading. Please reload this page.
[compaction] Session becomes permanently unusable on context overflow: token underestimation, summarizer replay overflow, and no manual recovery path
Environment
@deepseek-ai/dsh-root0.2.1-alpha.2 (checkoutd743267)dsh web(Web GUI)snq/qwen3.8-flash),context_window = 262 144, requestedmax_tokens = 32 768Summary
A session hit a hard
CONTEXT_WINDOW_EXCEEDEDwall and could not be recovered at all. Four compaction attempts (1 automatic mid-turn + 3 manual/compact) all failed with "Compaction could not produce a useful summary". The session was dead: every subsequent message (including bare?) reproduced the identical 400 error until manual surgery on the persisted JSONL was performed outside the harness.Three distinct problems compound here:
contextPressureunderestimates the real prompt by ~32% — automatic compaction never triggers before the wall.Repro (as observed)
Long session grows; at turns 75–76
contextPressure.surfaceTokensreported 155 094 / 262 144 (59%) → no pressure compaction.Send any message. The routed request actually contained ≥ 229 377 input tokens (server-side count) + 32 768 requested output = 262 145 > 262 144.
Automatic mid-turn compaction starts and fails immediately (
compaction/endwith error, 0 shadowed seqs) because the summarizer replays the full ~229k-token surface to the same route → the auxiliary call also 400s./compact×3 →Compaction could not produce a useful summary.every time. Same root cause: the manual path feeds the summarizer the whole shadowed span it is supposed to remove.Every later user message reproduces the identical 400. Session permanently wedged.
Actual behavior
surfaceTokens = 155 094) diverged from the provider's actual prompt size (≥ 229 377) by ~74k tokens (~32%)./compactare guaranteed to fail whenever the overflowing region itself must be re-sent to the overflowing model.Expected behavior
prompt_tokensfrom the last successful request, or a conservative tokenizer margin per route), not only a local heuristic./compacton a wedged session is the last-resort escape hatch; it should never depend on the failing model's availability.Proposed fixes (in rough priority)
usage.prompt_tokenswith the harness estimate for the same request; keep a per-route correction factor and feed it intocontextPressureand the auto-compaction trigger. (Here one successful-then-overflow sample would have been decisive: 229 377 / 155 094 ≈ 1.48.)surface_est × route_factor + max_output > window.window − maxSummaryTokens − instruction, split the span into sub-spans, summarize each sequentially (each input bounded by the window minus everything outside the sub-span), then merge the summaries. Alternatively prune the largest tool-result nodes from the summarizer input only (they're being discarded anyway) before the call./compact --force(or a prompt after repeated summary failure) that replaces the selected span with a deterministic extractive stub (user prompts + assistant text, tool results dropped) without any model call, so a wedged session is always recoverable in-product.context_window_fallbackforpurpose: 'compaction'calls so operators can point auxiliary calls at a larger-window model.Additional observations (related, possibly separate issues)
assistant/attempt→compaction/start→step/end→turn/end(error)), i.e. it acts as recovery, not prevention — and per #2 above it could never succeed.compaction/end.errorwas persisted with an emptymessagein one attempt ({"error":{"message":""}}) — the failure reason (LLM 400) is lost in the log, making diagnosis from the artifact alone impossible.assertZstdHeaderFrame,session-persistence-jsonl/src/index.ts); a rewritten artifact violating this is silently dropped from the session list (listArtifactsswallowsSessionPersistenceCorruptionError). A "1 unreadable session (reason)" notice in the list UI would save users from thinking their history is lost.Workaround used (for reference)
Manual offline compaction: decoded
session.v4.jsonl.zstd, reconstructed the surface fromsurfaceOp, appended a hand-authored checkpoint transaction (compaction/start→compaction/summary→user/messagewithsource.kind=compact-checkpoint,surfaceOp:{op:'replace',startSeq,endSeq}→compaction/end) replacing nodes[6343..6645], then restarted the server. Surface shrank 162 → 9 nodes; session works again. This is exactly what/compact --forceshould do in-product.Artifacts available
Session id
session-045a335b-a215-4f66-8846-fdf125b0b8d7(cwdC:\Users\sergey.reshetov\deepseek\1) — full event log preserved, including the failing attempts and all four failed compaction transactions.All reactions