Repository navigation
[PR] fix: adopt the refold pipeline's Prepared on accepted overflow refolds (#2777) - #2785
ranxianglei wants to merge 1 commit into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3066-pr.2785.0b9163aThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2785.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 正在 review(不重做——这是已完成的 ework-agent-pr 工作,走拉分支核对 + CI 确认流程)。初步结论:方向正确、机制已在代码层面核实( |
#2777) An accepted overflow refold updated the wire body but left forward()'s local Prepared binding stale. The internal compression loop seeds its coreMessages from that binding, and a FAILED compress (e.g. invalid refs from the model's stale view) skips the post-compress fold refresh — so the continuation re-request rebuilt the original oversized message view instead of the accepted folded one, re-triggering upstream context overflow. - overflowRefold now returns { body, prepared }; handle.ts hands back the refold pipeline's Prepared alongside the body - relay.ts adopts both after a successful retry (failed retries unchanged); the #1884 lone-surrogate scrub still applies to the returned body - regression test in tests/issue1195-overflow-refold.test.ts: overflow -> summary -> accepted folded retry emitting compress(invalid refs) -> internal continuation must carry the folded summary + tail, not the pre-refold markers
19061fd to
093d41a
Compare
[bot] 🏷 Review 完成 — 可合并(wire 相邻变更,按 §7.4 由人工合并)。分支已 rebase 到当前 master(e7b94a2),新 head 结构化八问:
行为变更披露(旧→新):仅在被接受的 overflow refold 之后,内部工具循环续传请求的消息体改由被接受的折叠视图(fold 摘要 + 近期尾部)构成,而非 refold 前的未折叠视图。这是本修复的本意;该路径之外一切(正常轮次、失败重试、不可折叠 payload)逐字节不变。 过程备注:
|
Closes #2777
What
An accepted overflow refold updated the wire body but left
forward()'s localPreparedbinding stale (the callback mutatedpendingForward.*, which does not alias intoforward()'s parameter). The internal compression loop seeds itscoreMessagesfrom that binding, and a FAILED compress (e.g. the model citing refs from its stale pre-refold view) skips the post-compress fold refresh (core.ts: refresh only on non-FAILED proxy results) — so the continuation re-request rebuilt the ORIGINAL oversized message view instead of the accepted folded one, re-triggering upstream context overflow.Fix
overflowRefoldnow returns{ body, prepared };handle.tshands back the refold pipeline'sPreparedalongside the body.relay.tsadopts both after a SUCCESSFUL retry (if (refolded.prepared) prepared = refolded.prepared). Failed retries keep today's behavior exactly.Behavior change disclosure (old → new)
After an ACCEPTED overflow refold, the body of subsequent internal tool-loop continuations is now composed from the accepted folded view (fold summary + recent tail) instead of the pre-refold unfolded message view. This is the intended fix. Outside that path nothing changes: the hook only exists when a prepared forward is present, fires only on a stated-window overflow 400/413, and adoption happens only when the retry is accepted. Client-visible behavior for normal turns, failed retries, and unfoldable payloads is byte-identical (regression cases A/B/C unchanged and green).
Tests
tests/issue1195-overflow-refold.test.ts: overflow 400 → preflight summary → accepted folded retry emittingcompress(startId=m00042,endId=m00099)(invalid refs) → asserts the internal continuation carries the fold summary + recent tail and omits the folded early markers. Verified FAILING on master without the fix, PASSING with it.context-overflow,e2e-overflow-selfheal,refold-wiring,issue2484-overflow-and-summary(37 tests) + the full 4-case refold suite.npm run typecheckclean;npm run buildclean (dist built at the PR head).ACP_TEST_E2E=1) could not run in this environment (no local LLM upstream available here); CI covers it forsrc/server/**changes.