Repository navigation
fix: forward over-window payload when preflight is exhausted (#333) - #334
ranxianglei wants to merge 1 commit into
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-334Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr334.tgz
npm install -g packageThis comment is automatically updated on each push. |
[bot] Reviewing PR #334 now — fetched head |
[bot] Review 完成,LGTM ✅ 在 PR head 代码与描述一致
self-heal 链路真实可达(新测试断言有据)
无回归
Pre-flight(独立重跑)
一个已知权衡(非阻塞,仅记录):若 bili 的窗口限制恰好是 ground truth(非 fallback/learned 估计),转发会每次重试多消耗一次注定 400 的上游请求。但系统会收敛(客户端拿到真实 400 + self-heal 学到真实窗口),而非旧行为的永久 livelock——与 #333 里你选定的方向 A(最小语义破坏)一致,可接受。 可以合并(按规则由你操作)。 |
|
Closing as superseded by PR#337, which implements the issue's preferred fix direction (relax the soft-protected recent zone oldest-first, hard This PR took the issue's explicitly-"weaker alternative" (forward-as-is and let the upstream arbitrate). It also references #333, which is a different issue (compaction_trigger mutation) already fixed by the native-compact interception. Nothing against the implementation itself — reviewed clean at the time — it's just the wrong direction to keep alongside #337, and the two are semantically exclusive. |
What
Fixes the preflight fail-fast × soft-protection livelock (#333): when the payload is over-window and there is nothing left to fold (all remaining messages sit in the soft-protected recent/last-user zone), the proxy used to fail-fast 502 on every retry — a permanent loop, because that state is static and the EMERGENCY nudge can never reach the model (fail-fast is exactly what blocks the request from arriving).
Implements fix direction A from the issue (author's stated preference: minimal semantic break):
src/server.tspreflightCompressIfNeeded— both exhausted sites now forward the payload as-is with a warning instead of fail-fast 502:failure.kind === "exhausted"(budget exhausted / ranges no longer resolve / nothing viable). If preflight partially compressed first, the rebuilt payload (with the partial compression kept) is forwarded.429 → 503 + Retry-After: 30, other → 502) and client abort. Those self-recover on retry; exhaustion does not.Why forwarding is safe (and heals)
The window limit bili enforces is often a fallback/learned/relay estimate, not ground truth. Forwarding lets the truth decide:
compress— the recovery path fail-fast had cut off.Tests
tests/preflight-fail-fast.test.ts:learnedContextLimits["claude-small"] === 8000);Pre-flight
npm run typecheck— cleannpm test— 746/746 passnpm run build— clean