Repository navigation
fix: rescue context-overflow turns in-request instead of arming a rescue that never comes (#1195) - #1328
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-1328Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr1328.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review started. PR #1328 ( |
…cue that never comes (#1195) Wire clients (pi/omp on the plain proxy path) treat an upstream context-overflow 400 as fatal and end the session, so the #987 arm-and-fold-on-the-next-turn recovery never gets its next turn and the session locks. When forward() sees a context overflow with a stated window, re-run prepare+preflight under the session lock with the stated window as a per-call limit override, fold the payload below the REAL window, and re-send it once within the same request. Nothing is learned; the declared window keeps governing (#987). An unfoldable payload keeps today's verbatim passthrough; a rejected retry passes the RETRY's verdict through, not the stale first 400. Fixes #1195
8b5fa77 to
ac6a538
Compare
[bot] 🏷 Review complete — mergeable. Full walkthrough below (direction → regression → code → tests → diff), plus one action I took directly on the PR branch. ① Original issue direction (#1195)Verified against the #1195 thread: this is the genuine-upstream-400 case (owner cross-determination floor 35), not the #1310 fake local reject — the ledger is honest, the wire really is over, and pi/omp treat an overflow 400 as fatal, so #987's armed rescue never gets its "next turn". Layer judgment: the fix targets the correct layer. It does not mask (no filtering/rewriting of the error or payload), it does not treat the symptom at the wrong boundary (the fold happens in preflight under the session lock, then the real folded body is re-sent — the client-visible contract only improves). It also correctly refuses to over-reach: nothing is learned ( ② Regression review — existing behaviors on touched paths
Minor nits found (non-blocking): (a) ③ Test validity
④ Verification performed (rebased head)
Diff cleanliness3 files, every line serves the fix; no whitespace churn, no generated artifacts, no version bump. Clean. 中文摘要:修复了 #1195「上游报窗口溢出 400 后救援永远等不到下一轮、会话锁死」的问题——在同一个请求内用上游声明的真实窗口重跑 prepare+preflight 折叠并重发一次(不学习、不改声明窗口、不可折叠时原样透传原 400),已本地验证 rebase 后全绿并直接把分支 rebase 推到了当前 master,可以合并。 |
Problem
#1195: after a successful ACP compression, the next request still dies with an upstream
Prompt is too long400 and the session locks. Root cause (verified against pi/omp sources): wire clients (pi / omp on the plain proxy path) treat an upstream context-overflow 400 as fatal — they end the session on the spot. The existing #987 recovery arms a one-shot emergency shrink and waits for the next turn to fold. That next turn never comes: the client has already given up. Session locked.This is the mirror image of #1310: there the ledger lied while the wire was fine; here the ledger is honest, the wire really is over, and the rescue itself is unreachable.
Fix
When
forward()sees an upstream context overflow (400/413 matching the overflow patterns) and the error states a window:armOverflowShrink, once per request);modelContextLimitoverride — the fold the declared window could never trigger now runs against the REAL window;Nothing is learned (#987 keeps governing: no
confirmedContextLimits, declared window unchanged) — the override is per-call, scoped to the rescue only. The#496image-forward-once hatch stays closed on the retry (the arm setslastInputTokensSource="usage").Tests
tests/issue1195-overflow-refold.test.ts(new, red-on-master):overflowArmTokens, 「BUG」sideRequestGuard 会永久拦截进程内第三方插件的 LLM 调用,导致与MemOS冲突 #1110) stays at the stated window minus the fold's reclaim credit.tests/e2e-overflow-selfheal.test.tsT1 updated: the stated-window case now ends 200 (in-request rescue), asserts context window problem continues #987 no-learning, test: pin the overflowArmTokens one-shot RELEASE direction (arm → real usage report → cleared → side request forwards again) + restart round-trip #1129 arm retirement by the retry's usage, and that the fold is sticky on the next turn. T2/T3 unchanged and green.omp-native,opencode-native,opencode-v2,pi-native,plugin-agent;dsh-nativeexcluded as always;index-entry-guardfails on the master worktree only for lack ofnode_modules).npm run typecheckclean.Fixes #1195