Skip to content

[PR] fix: detect upstream-clipped usage reports so nudge fires on multi-MiB sessions - #7446

Open
ranxianglei wants to merge 1 commit into
masterfrom
2026-11-21_fix-agy-cli-clipping-nudge-idle
Open

ranxianglei wants to merge 1 commit into
masterfrom
2026-11-21_fix-agy-cli-clipping-nudge-idle

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Problem

agy-cli (opencode-agy-cli-auth) clips replayed history to 112 KiB (maxInitialPromptBytes, agy.exe's 128 KiB ACP prompt limit) on every replay (no_live / drop_live / model switch). bili forwards the full 7.0 MiB history (1287 msgs, ~2M chars), agy-cli clips it to 41 msgs / 44.5 KB, agy.exe reports [acp-usage] input=50032. The existing anchorImpossible guard cannot catch this: condition B requires the current payload to tower 8x over the producer's snapshot, but both are ~2M chars (bili sent the full history both times).

Result: nudge idle on a 7.8 MiB session — the core compression promise silently fails.

Root cause

The usage report (50032) describes the CLIPPED payload, not the full payload bili sent. The anchorImpossible guard's condition B (payloadUpperNow >= lastUsagePayloadUpper * 8) cannot fire when bili sent the full history both times — the clip happens upstream, invisible to bili.

Fix

Add a reportClipped condition to effectiveTokenCount that gates both usage-returning branches (main usage + grade), falling through to the local estimate so the nudge sees the true payload size and fires.

The condition: localInputEstimate >= lastInputTokens * 16 AND localInputEstimate >= 500_000 (chars). The 16x ratio (vs the 8x SIDE_LANE_ANCHOR_IMPOSSIBLE_RATIO) and the 500K-char floor together distinguish true clipping (agy-cli: 2M chars / 50032 tokens = 40x) from honest under-reports on dense code (#1820 B e2e: 186K chars / 5000 tokens = 37x, below the 500K floor).

Behavior change (old → new)

Tests

Closes #7444

…B sessions (#7444)

agy-cli (opencode-agy-cli-auth) clips replayed history to 112 KiB
(maxInitialPromptBytes, agy.exe's 128 KiB ACP prompt limit) on every
replay. bili forwards the full 7.0 MiB history, agy-cli clips it to
41 msgs / 44.5 KB, agy.exe reports [acp-usage] input=50032. The
existing anchorImpossible guard cannot catch this: condition B
requires the current payload to tower 8x over the producer's snapshot,
but both are ~2M chars (bili sent the full history both times).

The distinguishing fact: the outbound char-bound (localInputEstimate)
towers 16x+ over the report AND is itself multi-megabyte (>= 500K
chars). An honest report of a small-to-medium payload can
legitimately under-report by 16x+ on dense code (#1820 B e2e: 186K
chars over a 5k report = 37x), but the clipped-payload class only
manifests on multi-MiB sessions where the upstream's byte cap is far
below the forwarded history.

The fix adds a reportClipped condition to effectiveTokenCount that
gates both usage-returning branches (main usage + grade), falling
through to the local estimate so the nudge sees the true payload size
and fires.

Closes #7444
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-21_fix-agy-cli-clipping-nudge-idle (f79279b)

Latest build — install this exact version

npm install -g billion-context@0.0.11176-pr.7446.f47f8c6

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
f79279b billion-context@0.0.11176-pr.7446.f47f8c6 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr7446.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix: detect upstream-clipped usage reports so nudge fires on multi-MiB sessions [PR] fix: detect upstream-clipped usage reports so nudge fires on multi-MiB sessions Nov 21, 2026

This branch has not been deployed

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

Labels

Projects

None yet

1 participant