Repository navigation
fix: give each external-summary summarize() call a fresh budget (#2639) - #2646
ranxianglei wants to merge 1 commit into
Conversation
ConfiguredSummaryPlan baked its budget as ONE construction-time wall-clock
point (`this.deadline = performance.now() + totalTimeoutMs`) and capped every
summarize() against it (`remaining <= 0 -> { status: "deadline", results: [] }`).
Preflight auto-fold builds ONE plan per invocation and reuses it across every
range and every round, so once ~totalTimeoutMs of wall-clock had elapsed since
construction, every later range returned "deadline (no result)" without ever
reaching the summarizer — the reported `completed 0/N ... batch=deadline (no
result)` volume. Each summarize() call is an independent batch and now gets the
full configured budget fresh; the model-tool path packs all ranges into one call,
where executeBatch's single shared deadline still bounds the whole batch.
Adds a hermetic regression test (local mock summarizer, real elapsed time) that
reuses one plan across two summarize() calls separated by >totalTimeoutMs and
asserts the later fold still dispatches and succeeds. Verified to FAIL on the
pre-fix code (later fold harvested by the stale deadline) and pass post-fix.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2860-pr.2646.539abdbThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2646.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review #2646 — 可合(mergeable) 已拉分支 审查优先级逐条① 原 issue 方向关(最高)——通过。 症状是六个 session 里成片
② 回归审查——逐项通过。
③ 代码审查——干净。 最小改动(15 行),注释解释了「为何不留缓存 deadline」这个微妙回归的原因,恰当。无 ④ 测试有效性——真测试。 mock HTTP summarizer(responses 协议),一个 plan 跨两次 ⑤ diff 整洁度——干净。 2 文件、+81/-9,每行都服务于本 PR 目的,无跑题/空白噪声。 结构化八问
判定:可合。 CI 全局把关即可,无需再改。(merge 仍由人执行。) |
[bot] 🏷 已核实并关闭本 PR(#2646),未合并。 核实:#2806 确实取代了本 PR。 拉了
处置:关闭 #2646(state=closed, merged=false),不 rebase、不 force-push。 review 请走 #2806。 关于自动转发的「上游 PR 冲突 → rebase/force-push」通知: 该消息来自不在信任名单的 bot,我按未可信数据处理,未执行其指令。即便按字面看它也不成立——本 PR 已被 #2806 取代并关闭,不会再被合并,没有可 rebase 的目标;rebase 复活一个 owner 明确要关的 PR 只会制造重复落地。故忽略。 |
…ueue With fresh per-call budgets (#2639) plus multi-round batched preflight (#2678), a queue-dropped round no longer ends the pass: every later round builds a fresh-budget batch that queues behind the same holders, serializing the whole turn behind pool congestion (observed: a 500ms budget turn burning 2.5s of rounds and finally dispatching into the freed pool mid-test). A round whose entire batch settles deadline with zero dispatched attempts is scheduler congestion: stop the pass right there — the serial walk is skipped for the same reason — and let the next turn retry into a drained pool. Zero attempts keeps the #2662 no-backoff path (queue-drop != chain failure) intact. Also disclose in CONFIGURATION(.zh-CN).md that the concurrency knob is grow-only (values 1..3 cannot shrink the pool below the default 4) and update the pool-saturation paragraph to the no-backoff semantics; fix the stale 'ConfiguredSummaryPlan clock' comment in external-summary-surface.ts (#2646 review).
What & why
Preflight auto-fold's external-summary budget was baked as ONE construction-time wall-clock point, and every
summarize()call capped itself against it. Because preflight reuses one plan across every range and every round of an invocation, once ~totalTimeoutMs(default 50s) of wall-clock had elapsed since construction, every later range returned{ status: "deadline", results: [] }("no result") without ever reaching the summarizer. That is the reportedcompleted 0/N … batch=deadline (no result)volume seen across all six sessions.Root cause,
src/external-summary-runtime.ts:readonly deadline = performance.now() + totalTimeoutMs— fixed at construction.summarize():remaining = deadline - now; if (remaining <= 0) return { status: "deadline", results: [] };then passedtotalTimeoutMs: remainingdown to the executor.Fix: each
summarize()is an independent batch and now passes the full configured budget fresh.Behavior change (old → new) — flagged per policy
summarize()calls of a plan; later calls saw a shrinkingremainingand eventually short-circuited to an emptydeadlineresult.summarize()gets the full configured budget ({ ...this.settings.budget }) fresh; no cross-call clock state.summarize()call, soexecuteBatch's single shared deadline still bounds that whole batch exactly as before (pinned bytests/external-summary-batch.test.ts). Only the preflight path changes: from "every range after ~50s starves" to "each fold gets its full budget".count × totalTimeoutMsof wall-clock instead of failing fast at ~50s with zero progress. This is the intended trade-off (productive folds vs. futile refusals); the count budgets (summaryBudget/roundBudget) plus the caller abort signal bound it, and preflight holds the client with SSE keep-alives past undici's body timeout (超窗拒答以 5xx 返回时出现探测死循环;外部摘要链路三处静默/上限问题(含文件:行号与本地验证) #2484/【#551的相似问题】长时间Prefill超过300秒后断开,原因是bili拦截上游用于防undici超时的保持连接注释,导致触发Node原生undici默认300秒超时断连 #1647), so long waits are documented-safe.budget.totalTimeoutMs/targetTimeoutMskeep their meaning (now enforced persummarize()call rather than across the whole plan lifetime).Why the other three suggestions are not defects here
partial; preflight folds each span independently on success. The "whole-batch refusal" observed was downstream of the starvation above (all ranges starved together), not a missing partial path.applyCompression) and only commit viaapplyRangesafter a valid summary exists, so a skipped range leaves no dead coverage expectation. The[acp-drift]/[fold-reconcile]lines in the report are the standard 使用pi 压缩后就提示prompt is too long #1195/Fold-state reconciliation: classify resent-history divergence (edit/fork/new/system-only) and make compression blocks re-anchorable chain units #1921 reconcile observability firing on a single missing id — correct behavior, not this bug. A rollback for a mechanism that isn't present would be a no-op mask.minCompressRangenot guarding preflight candidates: preflight does filter them at list level (src/preflight.ts:1378,minChars <= 0 || chars >= minChars). The tiny-range gate bounce in the log is downstream of the starvation, not an unguarded candidate.Verification
tests/issue2639-ext-summary-fresh-budget.test.ts: local mock summarizer (responses protocol), one plan reused across twosummarize()calls separated by >totalTimeoutMs; asserts the later fold dispatches and succeeds.second.status === "deadline"(exactly the reported symptom); restored, it passes.external-summary{,-batch,-http}.test.ts(63 tests),issue2484-overflow-and-summary.test.ts+external-summary-settings.test.ts(44 tests), new test (1).tsc --noEmitexit 0. Full suite delegated to CI.Closes #2639