Repository navigation
fix(#1800): fold compressible text when images alone exceed the window estimate - #1801
Conversation
…w estimate On bytes-billing upstreams (unknown hosts) the conservative base64/4 image estimate can push the payload estimate over the context window while the TEXT portion still fits. The #496 arbitration branch returned `prepared` unconditionally in that case, skipping preflightCompress entirely and recording no compression state — so auto-compression stayed permanently disabled for image sessions (issue #1800: preflightCompress ran 0 times across the whole session while every request was forwarded). The branch now short-circuits ONLY when there is genuinely nothing to fold (compressibleRanges empty). Otherwise it remembers the arbitration, runs preflightCompress to fold the compressible text portion, and — if images alone still keep the residual estimate over the window with no upstream overflow evidence — forwards the folded payload for the upstream to arbitrate billing. The image rides along byte-exact either way. No config/env surface added. Adds tests/issue1800-image-arbitration-compress.test.ts pinning the regression (verified: fails without the fix with 0 summarization calls, passes with it).
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1827-pr.1801.2bc0c1eThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1801.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 ## Review: fix(#1800) — fold compressible text when images alone exceed the window estimate Reviewed against current master (branch is rebased, 0 commits behind at review time; single linear commit, diff confined to Verification performed (not just reading the diff)
|
[bot] 🏷 CI 状态更新(新 head 我推送到 PR 分支的 commit 没有自动触发 CI——本环境的 push 凭据属于 app token,GitHub 对其 push 事件不投递(与 release-manual 流程文档记录的 GITHUB_TOKEN 行为一致),所以 push 后 check-runs 一直为空。已按同样的回退模式手动 dispatch 了全部可触发的 workflow(ref=
未在新 head 上跑的仅剩 结论不变:可合并。 代码改动经回归审计无回归;我补的测试 commit( |
What & why
Fixes #1800 — on bytes-billing upstreams (unknown hosts), the conservative
base64/4image estimate can push the payload estimate over the context window while the TEXT
portion still fits. In that case the
#496arbitration branch returnedpreparedunconditionally, skipping
preflightCompressentirely and recording no compressionstate. Net effect: the compressible text was never folded even though it was foldable,
so auto-compression stayed permanently disabled for image sessions — the reporter's
session logged
preflightCompressrunning 0 times across the whole session whileevery request was forwarded.
Root cause (layered)
#496branch's early return conflated "nothing to fold" with "images dominate" — it exited beforepreflightCompressregardless of whether any compressible ranges existed.preflightCompressto fold the text portion, then — if images alone still keep the residual over the window with no upstream overflow evidence — forwards the folded payload for the upstream to arbitrate billing. The image rides along byte-exact either way.Behavior change (old → new)
Evidence
tests/issue1800-image-arbitration-compress.test.ts: fails without the fix (got 0 summarization calls) / passes with it.issue1800,issue496-forward-once-learn,issue767-pixel-billing,fix-488-multimodal= 19/19.tests/proxy-persist.test.ts"EPERM detector") passes in isolation → a full-suite ordering flake in the persistence layer, untouched by this diff; not a regression from this change.src/server.ts(the#496arbitration branch) + the new test. Rebased onto current master.Review notes
src/server.tspreflight) → human review, not auto-merge.e2e-codex(auto-triggered by thesrc/server.tstouch).Closes #1800