来源: ranxianglei/billion-context#645 分析 codex >100% 上下文显示时发现。
Background
#408 introduced the host-usage backfill: the proxy adds the tokens folded out of the forwarded view back into input_tokens, so the host sees the uncompressed baseline. It was introduced to fix omp's accounting (omp's formula providerPromptTokens − historyRewriteTokensRemoved collapsed to ~0% because bili never called omp's recordAnchoredHistoryRewrite).
But the backfill is a one-size-fits-all solution that does not match every host's accounting semantics. It has required reactive exemptions for:
The opencode gap (concrete bug)
armHostUsageCredit (src/server.ts:1833) exempts only pi, omp, and codex (by UA). opencode is a bili agent plugin exactly like pi/omp — it self-announces via x-bili-plugin: opencode, cancels native compaction, and lets the proxy own the ACP tools (src/agent/opencode.ts: "mirrors the pi/omp plugin") — but it is not in the exempt list. So opencode receives the backfill and very likely shows the same >100% display that pi/omp/codex did; it simply hasn't been reported yet.
The design problem
The backfill adds "folded-out tokens" to input_tokens for every host, but each host has different accounting semantics. A number that is right for one host's display is wrong for another's. Exempting hosts one-by-one as they report a broken display is whack-a-mole.
Proposed direction
Concrete steps
- (Quick fix) Exempt opencode from the backfill (add it to the exempt list in
armHostUsageCredit), like pi/omp.
- (Redesign) Flip the default to post-fold usage and make the baseline opt-in (per host, matching each host's accounting semantics).
Impact
来源: ranxianglei/billion-context#645 分析 codex >100% 上下文显示时发现。
Background
#408 introduced the host-usage backfill: the proxy adds the tokens folded out of the forwarded view back into
input_tokens, so the host sees the uncompressed baseline. It was introduced to fix omp's accounting (omp's formulaproviderPromptTokens − historyRewriteTokensRemovedcollapsed to ~0% because bili never called omp'srecordAnchoredHistoryRewrite).But the backfill is a one-size-fits-all solution that does not match every host's accounting semantics. It has required reactive exemptions for:
The opencode gap (concrete bug)
armHostUsageCredit(src/server.ts:1833) exempts onlypi,omp, and codex (by UA). opencode is a bili agent plugin exactly like pi/omp — it self-announces viax-bili-plugin: opencode, cancels native compaction, and lets the proxy own the ACP tools (src/agent/opencode.ts: "mirrors the pi/omp plugin") — but it is not in the exempt list. So opencode receives the backfill and very likely shows the same >100% display that pi/omp/codex did; it simply hasn't been reported yet.The design problem
The backfill adds "folded-out tokens" to
input_tokensfor every host, but each host has different accounting semantics. A number that is right for one host's display is wrong for another's. Exempting hosts one-by-one as they report a broken display is whack-a-mole.Proposed direction
input_tokensadd.hostUsageCredit: "off"switch (for zcode) is a step toward this, but it is a manual global opt-out. The cleaner end-state is: post-fold by default, baseline available where a host's accounting actually needs it.Concrete steps
armHostUsageCredit), like pi/omp.Impact