Skip to content

[PR] fix(plugin): tag-echo degenerate retry now forbids the render tags (#7440) - #7441

Open
ranxianglei wants to merge 2 commits into
masterfrom
2026-11-21_tag-echo-retry-nudge
Open

ranxianglei wants to merge 2 commits into
masterfrom
2026-11-21_tag-echo-retry-nudge

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

⚠️ MODEL-FACING TEXT CHANGE — adds one new model-visible nudge (DEGENERATE_RETRY_NUDGE_TAG_ECHO) for the tag-echo degenerate-retry shape. The existing generic DEGENERATE_RETRY_NUDGE is byte-unchanged and still used for every other shape.

What broke

When a model conditioned on tagged history emits only <acp> render tags, the tag-echo filter empties the turn and the one-shot degenerate retry re-issues with the generic continuation nudge — which never mentions the tags. The model repeats the echo, the retry degenerates too, the pipe emits the #870 fatal error, and the host re-requests the same prompt into a loop (39 consecutive degenerate turns reported on gemini-4-neon-xhigh via the OpenCode chat-completions lane, #7440).

The fix

The pipe now tells the refetch why the turn was empty via a hint (ContinuationRetryHint.sawStrippedEcho); the refetch picks the matching nudge:

  • tag-echo shape (only output was a stripped render tag): the new DEGENERATE_RETRY_NUDGE_TAG_ECHO, which names the discarded tags and forbids them — the one signal the model needs to break the echo.
  • every other degenerate shape (silent thought, draft/announce tail, zero-byte cut, reasoning-only cut): the unchanged generic nudge.

Applies to both plugin pipes (chat + responses). The retry body still merges the nudge into the last user turn (cache-proof contract intact); only the nudge text changes, and only for the tag-echo shape.

Regression tests

  • The pipe passes the hint on a tag-echo turn and not on a silent-thinking turn (both directions).
  • injectContinuationNudge / makeContinuationRefetch ship the tag-forbidding nudge on the wire when the hint is set and the generic nudge when it is absent.
  • cache-proof pins the tag-echo nudge in the end-to-end refetch (its degenerate case is a tag-only echo).

Notes

Closes #7440

…7440)

MODEL-FACING TEXT CHANGE: adds one new model-visible nudge
(DEGENERATE_RETRY_NUDGE_TAG_ECHO) for the tag-echo degenerate-retry
shape. The existing generic DEGENERATE_RETRY_NUDGE is byte-unchanged and
still used for every other shape.

When a model conditioned on tagged history emits ONLY <acp> render tags,
the tag-echo filter empties the turn and the one-shot degenerate retry
re-issues with the generic continuation nudge — which never mentions the
tags. The model repeats the echo, the retry degenerates too, the pipe
emits the #870 fatal error, and the host re-requests the same prompt into
a loop (39 consecutive degenerate turns reported on gemini-4-neon-xhigh
via the OpenCode chat-completions lane).

The pipe now tells the refetch WHY the turn was empty via a hint
(ContinuationRetryHint.sawStrippedEcho); the refetch picks the matching
nudge:
- tag-echo shape (only output was a stripped render tag): the new
  DEGENERATE_RETRY_NUDGE_TAG_ECHO, which names the discarded tags and
  forbids them — the one signal the model needs to break the echo.
- every other degenerate shape (silent thought, draft/announce tail,
  zero-byte cut, reasoning-only cut): the unchanged generic nudge.

Applies to both plugin pipes (chat + responses). The retry body still
merges the nudge into the last user turn (cache-proof contract intact);
only the nudge TEXT changes, and only for the tag-echo shape.

Regression tests: the pipe passes the hint on a tag-echo turn and NOT on
a silent-thinking turn; injectContinuationNudge / makeContinuationRefetch
ship the tag-forbidding nudge on the wire when the hint is set and the
generic nudge when it is absent; cache-proof pins the tag-echo nudge in
the end-to-end refetch.

Fixes #7440
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-21_tag-echo-retry-nudge (41aebed)

Latest build — install this exact version

npm install -g billion-context@0.0.11170-pr.7441.ea08a86

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
41aebed billion-context@0.0.11170-pr.7441.ea08a86 build
7c0b27a billion-context@0.0.11165-pr.7441.82017ca build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix(plugin): tag-echo degenerate retry now forbids the render tags (#7440) [PR] fix(plugin): tag-echo degenerate retry now forbids the render tags (#7440) Nov 21, 2026
Review supplement for the #7440 fix: the pipe-level hint tests only
covered the chat pipe. The responses pipe (pipePluginResponsesWithStrip)
carries the byte-identical hint line and the PR claims both pipes, so
pin the positive direction there too: a tag-only echo turn passes
{sawStrippedEcho: true} to the refetch.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Review of PR #7441 — pulled the branch, read the full diff against the pipe code, ran the targeted suites locally, and checked CI. Verdict: mergeable (human merge), pending CI on the new head.

查重 (dedup): 不重复 — the only open [PR] row targeting #7440 is this one. The sibling degenerate-retry PRs are distinct mechanisms: #5897 (opt-in switch + neutral wording), #6993 (terminal reachability / escape hatch), #4785 (draft-tail nudge wording), #7417 (turn-bleed, sibling of #7416). This PR (nudge selection by shape) is orthogonal to all of them; all four are still open, so no rebase pressure yet.

Labels: mirror issue labeled on pickup (bug, opencode, p2, pr, scope/wiring); the GitHub PR already carries bug / p2 / scope/wiring / opencode.

Verification

① Direction. The fix targets the right layer. The retry mechanism itself works (one-shot retry, #870 fatal on second degeneration); the gap is that the refetch cannot tell why the turn was empty, so the tag-echo shape gets a nudge that never mentions the tags. Fixing nudge selection at the decision point (the pipe knows sawStrippedEcho; the refetch picks the matching text) is the root-cause fix, not a symptom mask.

② Regression review — existing behaviors on the touched paths, item by item:

  • Generic DEGENERATE_RETRY_NUDGE: byte-unchanged; every non-tag-echo degenerate shape (silent thought, draft/announce tail, zero-byte cut, reasoning-only cut) still receives it — pinned by the new negative-direction tests (chat silent-thinking → no hint; makeContinuationRefetch without hint → generic nudge on the wire).
  • Degenerate gate: unchanged conditions, unchanged one-shot semantics, unchanged Plugin passthrough leaves the client an empty turn when the model echoes a render tag #870 fatal.
  • Retry body shape: unchanged — nudge still merged into the last user turn; cache-proof pins zero other churn and its degenerate case (a tag-only echo) now pins the tag-echo nudge end-to-end.
  • makeContinuationRefetch call sites (5 in src/server/relay.ts): signature-compatible (the hint param is optional).
  • Modes: plugin pipes only (chat + responses); proxy mode untouched.
  • No high-risk pattern: no semantic drift, no fail-fast→swallow, no threshold/timing/output-format change.

③ Code. Clean. ContinuationRetryHint is a type-only import in plugin.ts; the hint condition !stalledTail && sawStrippedEcho is correct — a stalled tail (draft/announce) delivered visible prose so it keeps the generic nudge, and a stripped echo + thinking turn legitimately gets the tag-forbidding nudge (the model did emit a tag). The new nudge constant uses hex-escaped \x3c/\x3e per KDD #2.

④ Test quality. The new tests have teeth: both directions of the hint at the pipe level, both directions of the nudge selection at the wire level (real HTTP body capture), and the cache-proof end-to-end pin. Not tautologies — each would fail if the hint wiring or the nudge selection regressed.

⑤ Diff. 4 files, +170/−14, every line on-topic; no lockfile/generated churn, no unrelated changes.

Review supplement (小问题直接修)

One gap found in review, fixed on the spot as a labeled test-only commit:

  • 41aebedfb8b test(plugin): pin the tag-echo hint on the responses pipe twin (#7440) — the pipe-level hint tests only covered the chat pipe, but the PR claims both pipes and the responses pipe carries the byte-identical hint line with no test pinning it. Added the positive-direction test (tag-only echo turn → { sawStrippedEcho: true } passed to the refetch). Targeted file now passes 27/27 locally (was 26).

CI

  • Previous head 7c0b27a24d8: fully green — 37 success + 21 skipped (gated e2e canary lanes), 0 failure, across all test shards (ubuntu 22/24, windows 22), static-gates, and every guard (kernel, pi-subagents, config-surface, version, lane, docs, lock, …). The 42 "cancelled" rows are the superseded first run.
  • New head 41aebedfb8b (test-only): CI re-running; branch is 2 commits behind master ([PR] fix: cap x-bili-pf-tail-ids at 160 ids and decouple the pf-seq stamp from the fastpath gate (#7367) #7381 pf-tail-ids cap) with zero file overlap → no rebase needed, mergeable: true.

⚠️ Model-facing text — consumption-chain check

The PR body correctly flags the new model-visible nudge. I walked the consumption chain: the new text ("Your previous response contained only internal <acp> metadata tags and was discarded. Do not output <acp> metadata tags. Continue now: …") carries no numbers, refs, or positions for the model to anchor and propagate — no phantom-value class. Adversarial pass: the model could echo the instruction itself as prose (cosmetic, harmless); it cannot mint a phantom ref. The generic nudge is byte-unchanged, so no other shape's model-visible text moved.

八问

  1. 是什么问题: 模型只输出 <acp> 渲染标签(tag-echo)时,过滤器把这一轮清空,一次性退化重试用的通用续写 nudge 完全没提标签,模型再次回显标签、重试也退化、Plugin passthrough leaves the client an empty turn when the model echoes a render tag #870 致命错误触发、宿主(OpenCode)反复重发同一 prompt 成环(gemini-4-neon-xhigh 上 39 连发,[opencode] Gemini 4 Neon xhigh echoes <acp> render tags into a #870 degenerate-turn loop #7440)。
  2. 什么原因导致的: 重试机制本身正常,缺的是 nudge 选择——refetch 不知道这一轮为什么是空的,tag-echo 形态和所有其他退化形态(静默思考、draft/announce 尾巴、零字节截断、纯 reasoning 截断)拿到同一句通用 nudge,而这句话对打破标签回显没有任何信号。根因 = nudge 文本对形态盲;修法 = 按形态选择。
  3. 影响范围与严重程度: 影响 plugin 模式会话(chat-completions + responses 两条车道)中「条件于带标签历史、只输出渲染标签」的模型行为。该形态下这一轮完全不可用——模型困在重发循环里没有出口,需用户人工介入;普通会话不受影响。p2(整体可用,特定形态硬循环)。
  4. 怎么修复的: pipe 通过 hint(ContinuationRetryHint.sawStrippedEcho)告诉 refetch 这一轮为什么空;refetch 按形态选 nudge——tag-echo 形态用新的 DEGENERATE_RETRY_NUDGE_TAG_ECHO(点名被丢弃的标签并禁止输出),其他形态用字节不变的通用 nudge。重试 body 仍把 nudge 合并进最后一个 user turn(cache-proof 契约不变),只有 nudge 文本变、且仅 tag-echo 形态变。
  5. 是否有回归问题: 逐项审过既有行为:通用 nudge 字节不变且所有非 tag-echo 形态仍拿到它(新负向测试钉住);退化门条件/一次性语义/Plugin passthrough leaves the client an empty turn when the model echoes a render tag #870 不变;重试 body 形状不变(cache-proof 钉住零其他变更);5 处 makeContinuationRefetch 调用点签名兼容(hint 可选);仅 plugin 模式,proxy 模式未动。无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式变化。无回归。
  6. 是否破坏缓存: 否。nudge 仍合并进最后一个 user turn(既有 cache-proof 机制),前缀字节稳定;仅 tag-echo 形态的合并文本不同。cache-proof 套件(钉住零其他变更)通过。
  7. 是否改了设计方向: 否。退化重试架构(一次性重试、nudge 合并、Plugin passthrough leaves the client an empty turn when the model echoes a render tag #870 致命)不变,只在既有 hint 缝内增加按形态的 nudge 选择;无架构/边界/数据流转向。
  8. 是否引入新配置: 否。无新 env、config key、默认值;新 nudge 常量为内部实现。

判定: 可合(人工合并) — 等新 head(仅测试提交)CI 转绿即可;本地定向测试 27/27 已通过。

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

Development

Successfully merging this pull request may close these issues.

[opencode] Gemini 4 Neon xhigh echoes <acp> render tags into a #870 degenerate-turn loop

1 participant