Repository navigation
[PR] fix: count mid-history sys/dev once in wire overhead instead of double-billing it (#6293) - #6474
ranxianglei wants to merge 3 commits into
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.9560-pr.6474.a589c56This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr6474.tgz
npm install -g packageInstall instructions are refreshed on each push. |
c89e75f to
3f38650
Compare
The fix commit referenced the internal mirror issue number, which points at an unrelated open PR on GitHub (and the PR body's Closes line would close that PR on merge). The bug report is GitHub issue #6291 — rename the test file to the repo's issue<N>- convention with the right number and repoint the src/server/budget.ts comments at it.
…s gate The byte-equality assertion stripped the proxy-stamped ACP tag line with a regex that REQUIRED the time="..." attribute. That attribute exists only when messageTimestamps is on (#4313, default ON in production); the CI suite pins it OFF via tests/preload-test-env.mjs, so the regex never matched and the assertion failed on every CI shard while passing in standalone local runs. Make the attribute group optional so the test is deterministic in both regimes (AGENTS.md 7.2: no environmental luck).
3f38650 to
2d3d56d
Compare
[bot] 🏷 查重: 不重复 — no other open/closed issue or PR fixes this double-count; the related prior work (#829 head counting, #3713 calibration denominator) is calibration, not this defect. Review verdict: mergeable after ONE human editThe code fix is correct, the CI red is root-caused and fixed by me, but the PR body's 1. CI red — root cause found, fixed, pushed (all 3 shards, one single test)All three failing shards (ubuntu 22/24, windows 22) failed on exactly ONE test each — the PR's own new e2e
Fix: the 2. Wrong GitHub number (must fix before merge)
3. Code review — the fix itself is correctVerified against the kernel codecs: 4. Minor findings (non-blocking)
Housekeeping I did
八问(结构化审核)
判定: 可合 — 前提两条:① PR body |
Closes #6293
What
estimateWireOverhead(src/server/budget.ts) double-counted mid-history system/developer text on the Responses and OpenAI lanes. The kernel projections (responsesToCore/openaiToCore) hoist only the LEADING run of sys/dev items out of the counted core view — mid-history sys/dev items are core messages, already billed byestimateCoreMessages— but the overhead estimator walked EVERY sys/dev item ininput[]/messages[]and billed the same bytes a second time. On cold-start requests with no usage baseline, core + overhead inflated the local estimate past the judging limit and tripped spurious preflight compression (reporter's 3 MB history: 1,170,334 estimated vs 705,090 true).Fix
The overhead side now counts EXACTLY the projection's hoisted set, using the same codec the core view uses:
responsesToCore(body).systemParts(instructions + leading sys/dev run)openaiToCore(body).systemText(leading contiguous prefix)Projection failure keeps the legacy all-sys/dev walk (fail-closed overcount — the call sites degrade to an empty core on the same failure, so nothing goes unbilled). Tools / loaded-tools / other-protocol logic untouched. No threshold, window, timeout, or request-body changes. No kernel changes (the codec was already exported).
Behavior change (old → new)
Tests