You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When routing agy-cli models through billion-context, nudge judges context usage from the upstream [acp-usage]input token count. However, opencode-agy-cli-auth clips replayed history to 112 KiB (maxInitialPromptBytes due to agy.exe's 128 KiB ACP prompt limit) whenever replay occurs (no_live / drop_live / model switch).
As a result:
billion-context forwards 7.0 MiB (1287 msgs, ~2,034,181 est tok),
agy-cli clips it to 41 msgs / 44.5 KB (prompt_bytes=113,708) before sending to agy.exe,
agy.exe returns [acp-usage] input=50032,
billion-context sees usage=5% (50032/983040) and stays nudge idle (growth 0 < floor 22500), never compressing the 7.8 MiB session!
Similarly, in another active session (ses_e03a1f678ffeIFNmz1CeEv6390), acp_status shows:
When outbound estimated tokens are vastly higher than the upstream [acp-usage]input tokens (e.g. outbound ~1.8M–2M est tokens vs input=50032, or outbound > 50% of effectiveWindow while acp-usage < 15%), nudge should fall back to billion-context's own outbound token estimate instead of staying nudge idle on the clipped upstream acp-usage.
查重: 不重复 — no existing issue/PR covers the upstream-clipped usage report class. The anchorImpossible guard (#4805) handles side-lane pollution (producer sent a tiny payload), not upstream clipping (producer sent the full payload, upstream clipped it invisibly).
Root cause:effectiveTokenCount's anchorImpossible guard (condition B: payloadUpperNow >= lastUsagePayloadUpper * 8) cannot fire when bili sent the full history both times — the clip happens upstream (agy-cli's 112 KiB maxInitialPromptBytes), invisible to bili. The usage report (50032) describes the clipped payload, not the 2M-char payload bili forwarded. Result: nudge idle on a 7.8 MiB session.
Fix: Added 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 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):
Old: on a multi-MiB session where the upstream clips the payload, effectiveTokenCount returns the clipped report (e.g. 50032) as source: "usage" → nudge idle.
New:effectiveTokenCount returns the local estimate (e.g. 2M chars) as source: "estimate" → nudge fires (EMERGENCY tier if over window).
Tests: New tests/issue7444-agy-cli-clipping.test.ts (6 tests). All 52 tests in the related suite pass (issue4805, issue4383, issue5134, side-lane-invariants, issue1820).
Activity
ranxianglei commentedon Nov 21, 2026
(ai: vllm-qwen/qwen3.8-27b)
查重: 不重复 — no existing issue/PR covers the upstream-clipped usage report class. The
anchorImpossibleguard (#4805) handles side-lane pollution (producer sent a tiny payload), not upstream clipping (producer sent the full payload, upstream clipped it invisibly).Fix
PR: #7446
Root cause:
effectiveTokenCount'sanchorImpossibleguard (condition B:payloadUpperNow >= lastUsagePayloadUpper * 8) cannot fire when bili sent the full history both times — the clip happens upstream (agy-cli's 112 KiBmaxInitialPromptBytes), invisible to bili. The usage report (50032) describes the clipped payload, not the 2M-char payload bili forwarded. Result:nudge idleon a 7.8 MiB session.Fix: Added a
reportClippedcondition toeffectiveTokenCountthat gates both usage-returning branches (main usage + grade), falling through to the local estimate so the nudge sees the true payload size and fires.Condition:
localInputEstimate >= lastInputTokens * 16ANDlocalInputEstimate >= 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):
effectiveTokenCountreturns the clipped report (e.g. 50032) assource: "usage"→ nudge idle.effectiveTokenCountreturns the local estimate (e.g. 2M chars) assource: "estimate"→ nudge fires (EMERGENCY tier if over window).Tests: New
tests/issue7444-agy-cli-clipping.test.ts(6 tests). All 52 tests in the related suite pass (issue4805, issue4383, issue5134, side-lane-invariants, issue1820).八问(中文,供 reviewer 参考):
是什么问题: agy-cli 在 replay 时把历史截断到 112 KiB,bili 转发 7.0 MiB 完整历史后上游只报告截断后的 50032 tokens,nudge 判断 usage=5% 保持 idle,7.8 MiB 会话永远不压缩。
什么原因导致的:
anchorImpossible守卫条件 B 要求当前 payload 比生产者快照大 8 倍以上,但 bili 两次都发送了完整历史(截断发生在上游,bili 不可见),条件 B 无法触发。usage report 描述的是截断后的 payload,不是完整 payload。影响范围与严重程度: 影响所有使用 agy-cli(或任何有 byte cap 的上游)的 multi-MiB 会话。核心压缩承诺静默失败——7.8 MiB 会话永远不压缩。
怎么修复的: 在
effectiveTokenCount中添加reportClipped条件(16x 比率 + 500K 字符下限),gate 两个 usage 返回分支,fall through 到 local estimate。是否有回归问题: 审了 post-rebuild usage estimate inflates ~3.4x after a big fold, firing an EMERGENCY T1 nudge into an over-budget context #1820 B e2e(dense code 37x ratio,186K chars)——500K 下限保护了 fast path。审了 Bypass requests overwrite the main session's usage anchor, causing long sessions to permanently stop compressing. | 旁路请求覆盖主会话 usage 锚点,导致长会话永久停止压缩 #4805 anchor pollution——所有 52 个相关测试通过。无回归。
是否破坏缓存: 不涉及。
是否改了设计方向: 不涉及。修改在现有函数内,无架构变更。
是否引入了新的配置: 不涉及。
[-][Bug][opencode/0.1.216] agy-cli 112 KiB replay clipping makes [acp-usage] report ~5% usage while outbound is 7.0 MiB, keeping nudge idle[/-][+][ai][Bug][opencode/0.1.216] agy-cli 112 KiB replay clipping makes [acp-usage] report ~5% usage while outbound is 7.0 MiB, keeping nudge idle | agy-cli 112 KiB 重放裁剪使 [acp-usage] 仅报 ~5%,导致 outbound 7.0 MiB 仍维持 nudge idle[/+]refactor: name the #7444 clipping-ratio constant