Repository navigation
fix(preflight): log+dump rejected summary bodies and shrink-retry hard 400/413 - #1994
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2009-pr.1994.c39b99dThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1994.tgz
npm install -g packageInstall instructions are refreshed on each push. |
|
On the single red check The failure is the freshly-merged perf pin Evidence it is pre-existing:
Likely mechanism: the warmup reconciles a 1K-message history, so the measured 8K rounds pay first-allocation cost for a size class never seen before. Min-of-3 absorbs GC/JIT spikes but not one-off page-fault/allocation cost of a fresh ~40MB working set, which appears much more variable on Windows runners (both failed runs show an elevated ~10ms t1k baseline for 1K messages). Failed job re-run requested on this PR. Suggested follow-ups (different mechanism than #1993, out of scope here — please file/decide separately): warm up at the measured size class before taking min-of-3, or make the ratio pin OS-aware. |
…d 400/413 (#1993) A preflight summarization call answered HTTP 400 left the session wedged and undiagnosable: the response body was never logged or dumped, there was no chunk-shrink fallback (unlike the unusable-HTTP-200 path), and the turn fail-fasted 502 retryable=false plus a dead-end cooldown. - surface the rejection body: bounded 200-char snippet in the warn log AND in the client-visible fail-fast detail (parity with the main request paths) - BILI_DUMP_4XX now persists the full summary exchange (request + response) as summary-err-*.json under the same gate/cap; separate prefix so it cannot clobber a main-path err-* dump in the same millisecond - hard (non-transient) 400/413 get the same halving recovery as an unusable 200 summary, bounded by MAX_SUMMARY_CALLS_PER_PREFLIGHT; transient 4xx keep replay-retry semantics, auth/routing 4xx fail fast without burning budget - clear a stale upstream failure after a successful fold so later exhaustion reports its own reason and fitting results report none Closes #1993
ff0d0d1 to
8a24c9e
Compare
[bot] 🏷 Review 完成(拉分支逐行核对代码 + 测试有效性 + CI + 对当前 master 的 rebase 验证)。 结构化七问
行为变更披露(旧→新):硬 400/413 时每次 preflight 调用的上游 summary 调用数:旧 = 恰好 1 次 → 新 = 最多到该次调用的 summary 预算。注意与 #1933 的叠加:master 上 #1933 已把固定 16 改成随 overshoot 动态的 我做的验证动作:
判定:可合 —— 等 8a24c9e 的 CI 转绿后人工合并即可。(自动合并门禁不过:运行时默认行为变更属产品决策,留在人工。) |
…ions (#1945 eventListeners + HostCtx type)
…e-narrow in #1987/#1994/ws-bridge tests - src/server.ts: re-export type ProxyOptions (issue1987/issue1993 tests import it from server.ts) - tests/issue1987-preflight-baseline-anchor.test.ts: address() as AddressInfo (×2) - tests/codex-responses-ws.test.ts: cast tools/input/error.error (×4 errors, type-level only) - tests/ws-bridge.test.ts: async void fallback handler + Promise<void> resolve Touched test files pass: 5+1+5+3. No runtime changes anywhere.
What
#1993: a preflight summarization call answered HTTP 400 left the session wedged and undiagnosable — the response body was never logged or dumped, there was no chunk-shrink fallback (unlike the unusable-HTTP-200 path), and the turn fail-fasted 502 retryable=false plus armed a dead-end cooldown.
Changes
safePrefix) goes into both thewarnlog line and the client-visible fail-fast detail, parity with the main request paths (src/loop/core.ts,src/server.ts).dumpSummaryRejection(status, sessionId, request, response)insrc/error-dump.tsunder the sameBILI_DUMP_4XX=1/BILI_DUMP_4XX_MAX_BYTESgate asdumpRejectedBody. Writessummary-err-<ts>-<sid>-<status>.json: a JSON envelope{status, request, response}with each side embedded as a string so the envelope stays valid JSON even when a side is not itself JSON. The distinctsummary-err-prefix keeps a main-path and a summary dump landing in the same millisecond from clobbering each other. Called fromrequestSummaryBodyat final throw for 4xx responses — the only site where both byte streams are in hand.MAX_SUMMARY_CALLS_PER_PREFLIGHTvia the existing while-top budget check). Transient 4xx (risk-control markers) keep replay-retry semantics; other 4xx (auth/routing) fail fast without burning the budget; unsplittable spans give up exactly as before.Behavior changes (old → new)
rejected by the upstream (HTTP 400): <first 200 chars of the rejection body>BILI_DUMP_4XX=1artifactserr-*.json)summary-err-*.json)result.failureafter a successful fold following an earlier rejectionDead-end cooldown semantics are unchanged: it still arms only on zero-progress failures — but a 400 now reaches that state only after the FULL shrink cascade is exhausted, which is what makes it genuine evidence (the issue's fix #5, resolved behaviorally without key surgery).
Deferred (owner decision)
The issue's fix #4 (learned per-endpoint summary input ceiling in session metadata) adds a persistence/metadata surface — owner-design territory per the config-surface discipline, so it is tracked separately instead of being built here.
Tests
tests/issue1993-preflight-400.test.ts: systemic hard 400 (snippet in client message AND warn log, bounded cascade ≥2 calls ≤ budget, nothing forwarded, cooldown arms with scoped key and replays with ZERO calls), size-driven 400 recovering via halving (end-to-end 200, failed-before-succeeded ordering, no marker left), 401 not shrinking (exactly one summary call), e2e dump-file assertion (envelope carries request+response bytes).tests/error-dump.test.ts: off-by-default gate, envelope round-trip, raw non-JSON sides, cap + truncation marker, empty-exchange skip fordumpSummaryRejection.Closes #1993