Repository navigation
fix: count responses input[] developer/system in preflight overhead estimate (#829) - #832
Conversation
…stimate (#829) estimateWireOverhead only read top-level instructions for the responses protocol. codex sends its whole system prompt as role=developer items inside input[] (top-level instructions empty), and the kernel hoists those out of the counted message view while the rebuild strips instructions — so the entire system prompt was invisible to the preflight gate, systematically under-counting codex-shaped sessions by ~6-9k tokens and deferring compression. Count the developer/system items in input[] (mirrors the openai branch). Recalibrated 5 test harnesses whose 10k windows were tuned against the old under-count to 15k, added regression tests. Pre-flight: typecheck clean, 1652 tests / 1650 pass / 0 fail / 2 skipped (e2e-gated), build OK.
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-832Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr832.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review complete — the fix is correct, I found and fixed one missed test calibration on the branch, CI is now fully green. Details: Bug verification (#829) — confirmed at code level against acp-kernel 0.0.74:
The fix targets the root cause (the overhead estimator), not the symptom (the stale-baseline escape). The flagged behavior change — codex-shaped sessions triggering compression earlier — is agreed as intended; that's the whole point of #829. Local verification: typecheck clean; 1652 tests / 1650 pass / 0 fail / 2 skipped (e2e-gated); build OK. Matches your pre-flight claims. CI finding → fixed directly on the branch: your first push failed the Also checked The diff is clean: every hunk is either the overhead fix or its calibration fallout (including my one-line window bump). Since this miscalibration is the exact class #829 predicted ("~13 test windows calibrated on the old under-count"), fixing it inside this PR rather than a follow-up issue keeps the calibration complete in one shot. Merge is human-only — everything is ready: #832 修复了 e2e-fake 测试窗口漏校准的问题(12k→24k,新计数下真实 codex 首轮下限约 18.4k 导致 CI warmup fail-fast),已在 PR 分支直接补上并用真实 codex 本地验证、CI 全绿,本 PR 可以合并。 |
|
继续 |
|
冲突 |
…onses-overhead-devsystem
冲突已解决,分支已更新到当前 master( The conflict — one hunk,
Resolution: kept 24k. The two calibrations measure different things — preflight fail-fast compares the local Everything else auto-merged cleanly — notably Verification on the merged tree:
Head is now 中文一句话:解决了与 master 的合并冲突(e2e-fake 溢出测试的窗口值两边都改了),保留本分支的 24k——因为 preflight 快速失败比较的是本地估算值而非上游报告的 token 数,master 按报告值校准的 10k 会在第一轮回暖时复现同样的 502;合并后 typecheck/全量测试/构建全绿,并用真实 codex 跑通了该 e2e 套件,可以合并。 |
|
ci失败 |
…#832) CI failed with 'got 1' summary: the 24k window was calibrated on a leaky local env (TMPDIR inside the repo tree -> codex discovered repo AGENTS.md from its cwd, inflating every payload). In a clean env the turn-1 estimate is ~15.3k and the crossing only happened on the last load turn, leaving a single fold. - window 24k -> 18k: clears the overhead-only floor (~14k est) so no warmup fail-fast 502, while preflight engages from turn 2 - filler 300 -> 600 lines: decisive crossing by turn 2, repeated folds inside the five load turns, forwarded payload stays flat (~57-58k) - skip guard: if .git/AGENTS.md sits above the hermetic cwd, skip the calibrated test with an actionable reason instead of mis-calibrating
CI fixed — all checks green on What failed: the overflow test asserted ≥2 summarization calls but CI saw exactly 1 (the fold only happened on the last load turn). Root cause: my merge-conflict resolution kept a 24k window calibrated on my local sandbox — which turned out to be leaky: its Fix (
Evidence:
PR remains open for you to merge — #832 中文摘要:CI 失败根因是冲突解决时保留的 24k 窗口按"仓库文档泄漏进载荷"的本地环境校准,干净 CI 环境下首轮估算仅 ~15.3k、直到最后一轮才触发压缩(仅 1 次);已改为 18k 窗口 + 加倍填充使压缩从第 2 轮起反复发生,并新增"cwd 上方存在 .git/AGENTS.md 则跳过并提示"的守卫防止再次错校准,CI 现已全绿,可以合并。 |
Fixes #829
Problem
estimateWireOverhead(insrc/server/budget.ts) only read top-levelinstructionsfor the responses protocol. codex 0.147.0 sends its whole system prompt asrole=developeritems insideinput[](top-levelinstructionsstays empty). The kernel hoists those out of the counted message view (projection.systemParts), and the rebuild stripsinstructionswhile re-injecting the system text back intoinput[]as a developer message — so the entire system prompt was invisible to the preflight gate.Result: codex-shaped sessions were systematically under-counted by ~6–9k tokens (the whole system prompt). When reported usage lagged real payload growth (first-turn unknown baseline, client history jumps, providers not reporting usage), the gate kept taking the stale-baseline escape ("trigger fired on a stale baseline but the payload fits; forwarding as-is") and deferred compression until
payloadEstimateitself climbed past the window → context-overflow risk.Fix
Count the
developer/systemitems insideinput[]for the responses branch (mirrors the existing openai chat branch). Handles both content shapes: plain string and array ofinput_text/output_textparts.Note: this also now counts the always-injected compress/absorb prompts (they ride the wire in the rebuilt developer item) — correct, since they consume context, but it raises the calibrated overhead for all responses sessions.
Behavior change
Real codex users will now trigger compression earlier (the gate sees the true payload size). This is intended — it removes the systematic under-count. Flagging per the #829 note so it's evaluated as a deliberate behavior change before release.
Tests
tests/wire-overhead.test.ts: dev/system counted, user/assistant not; array-of-parts content joined; top-level instructions + input[] dev combined.codex-compact-e2e,compaction-trigger-finality,host-usage-postfold, and the two fix: Codex preflight summaries fail with unsupported max_output_tokens #663 tests inpreflight-max-output-tokens.compaction-trigger-finalityalso moves the reported usage 9000→13500 to preserve its 90% ratio.Pre-flight