Skip to content

Redesign #408 host-usage backfill: post-fold by default, baseline opt-in (opencode gap + whack-a-mole exemptions) #660

Description

@ranxianglei

来源: 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

  1. (Quick fix) Exempt opencode from the backfill (add it to the exempt list in armHostUsageCredit), like pi/omp.
  2. (Redesign) Flip the default to post-fold usage and make the baseline opt-in (per host, matching each host's accounting semantics).

Impact

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions