Skip to content

[PR] fix(server): side-lane requests skip the degenerate-turn gate (#6466) - #6475

Open
ranxianglei wants to merge 3 commits into
masterfrom
2026-11-13_side-lane-skip-degenerate-gate
Open

ranxianglei wants to merge 3 commits into
masterfrom
2026-11-13_side-lane-skip-degenerate-gate

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #6466

What

A side-lane request (dsh title-gen / auto-review / single-shot) is a best-effort utility call that rides the non-injected streaming branch. It previously received a live continuation refetch, so the pipe's degenerate-turn gate (#732/#821 retry + #870 in-band error) fired for it: a title request that came back with no visible text (reasoning-only under effort=max) was re-issued (double-billing a utility call) and, on a second empty response, the client got an in-band stream error that DSH wrote into the session title (❌ [ACP] stream error: the turn degenerated again ...).

Fix

Pass refetch=undefined for sidePassthrough requests in the non-injected streaming branch (src/server/relay.ts). refetch=undefined disables the pipe's degenerate gate (retry + #870) AND the cut retries. The non-side-lane non-injected path keeps the gate unchanged (the ternary is a no-op for it). The non-streaming JSON pipe and the commandcode JSONL pipe take no refetch, so no other call site is affected.

Behavior change

Tests

tests/issue6466-side-lane-skip-degenerate-gate.test.ts drives a degenerate (echo-only) SSE turn through the relay hermetically, asserting both directions (gate discipline #3617):

Reverting the relay ternary turns the side-lane case red (bug reproduced). Typecheck clean; related existing suites (plugin-empty-turn-retry, dsh-title-sidecar-handle, side-lane-truth-table, issue2756-degenerate-gate, side-lane-invariants) all green.

ci-check added 2 commits November 13, 2026 05:54
…#6466)

A side-lane request (dsh title-gen / auto-review / single-shot) is a
best-effort utility call that rides the non-injected streaming branch. It
previously received a live continuation refetch, so the pipe's degenerate-turn
gate (#732/#821 retry + #870 in-band error) fired for it: a title request that
came back with no visible text (reasoning-only under effort=max) was re-issued
(double-billing a utility call) and, on a second empty response, the client got
an in-band stream error that DSH wrote into the session title.

Pass refetch=undefined for sidePassthrough requests, which disables the pipe's
degenerate gate AND the cut retries. The non-side-lane non-injected path keeps
the gate unchanged (the ternary is a no-op for it). The non-streaming JSON pipe
and the commandcode JSONL pipe take no refetch, so no other call site is
affected.
Drive a degenerate (echo-only) SSE turn through the relay hermetically:
- side lane (dsh title sidecar, stream): ends as-is — 1 upstream hit, no
  retry, no #870 in-band error.
- control (non-side-lane non-injected main turn, stream): still retries once
  and escalates to the #870 in-band error — the main path is unchanged.

Gate discipline #3617: both directions asserted. Reverting the relay ternary
turns the side-lane case red (bug reproduced).
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-13_side-lane-skip-degenerate-gate (9bbadd8)

Latest build — install this exact version

npm install -g billion-context@0.0.9525-pr.6475.7f47fff

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
9bbadd8 billion-context@0.0.9525-pr.6475.7f47fff build
652cad4 billion-context@0.0.9408-pr.6475.1ce53ed build

Download artifact

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

Install instructions are refreshed on each push.

…ted vehicle (#6466)

#6466 removed the side-lane continuation refetch (side lane ends as-is), which
broke the two #4204 tests that used a side-lane degenerate turn as the vehicle
to trigger the continuation refetch. Re-target both to a main-lane (non-side)
non-injected request (budget > 200), which still performs the continuation
refetch, so the #4204 429-scoping mechanism keeps its e2e coverage.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

查重: 不重复 — the only adjacent open PR is #5897 (empty-turn continuation retry off by default + neutral nudge wording). Different mechanism: #5897 makes the empty-turn continuation retry opt-in wholesale; #6466/#6475 makes side-lane (title-gen / auto-review / single-shot) skip the degenerate-turn gate. Same "empty-turn / continuation retry" family, but not a duplicate — worth keeping in mind for interaction when both land.

Review: PR #6475 — side-lane requests skip the degenerate-turn gate (#6466)

Verdict: mergeable. The core fix is correct; I found and fixed the one CI regression it introduced; all 12 CI workflows now pass on the updated head.

What I verified

Core fix is correct. The non-injected streaming branch now passes refetch=undefined for sidePassthrough requests (src/server/relay.ts). I traced the pipe semantics in src/plugin.ts: refetch === undefined gates the entire degenerate-turn machinery — the empty-turn retry (retryEmptyTurn, line 2912: if (refetch === undefined || truncationRetried) return false), the #870 in-band escalation (unreachable — degenerateRetried is only set inside the retry path, line 2962), and the cut retries (lines 3014/3061). maybeWarnDegenerate is refetch-independent, so the observability warn still fires. The PR's claim is accurate.

Branch structure is sound. The fixed branch is the only place a side-lane streaming request could carry the gate. The reasoning-guard branch (line 2357) and the fake-completion retry (line 2396) already exclude !prepared.sidePassthrough; the resetAfterSuccess branch is main-lane only; the non-streaming JSON pipe and the commandcode JSONL pipe take no refetch. No other call site is affected.

The new test has teeth. tests/issue6466-side-lane-skip-degenerate-gate.test.ts asserts both directions (gate discipline #3617): side-lane degenerate SSE ends as-is (1 upstream hit, no retry, no #870), and the control (non-side-lane non-injected) still retries once + escalates to #870. I reverted the relay ternary locally and the side-lane case went red (upstreamHits expected 1, actual 2 = the double-bill retry) — the test genuinely pins the fix.

Regression I found and fixed

The PR's first head failed CI on 3 shards (deterministic, not flake) with the same 2 tests:

  • #4204 side-lane continuation 429 remains scoped to its request model (tests/proxy-noinject-tag-strip.test.ts:479)
  • #4204 Google side-lane stream keeps its path model through continuation throttling (tests/proxy-noinject-tag-strip.test.ts:545)

Root cause: both #4204 tests used a degenerate side-lane turn as the vehicle to trigger the continuation refetch, then asserted the 429 on the refetch is model-scoped (KeyRing marker) not credential-wide. #6466 removed the side-lane refetch, so hits() dropped to 1 and the assertions failed before reaching the 429-scoping lines. The PR's listed suites didn't include proxy-noinject-tag-strip.test.ts.

Fix (pushed as commit 9bbadd8a51): I re-targeted both tests' vehicles from side-lane to main-lane (non-side) non-injected (budget raised above 200: max_tokens: 100→4096, maxOutputTokens: 64→1024), which still performs the continuation refetch. This preserves the #4204 429-scoping e2e coverage while matching the new reality. The #4204 mechanism also stays unit-covered by tests/issue4743-degenerate-refetch-429.test.ts and tests/issue4204-throttle-governor.test.ts.

Verification on the updated head (9bbadd8a51):

Behavior change (disclosed)

Merge-readiness note

The PR is 50 commits behind master (busy repo) but mergeable with no conflicts, and I confirmed the 50 new master commits don't touch any of the PR's files (src/server/relay.ts, src/plugin.ts, the two test files). Safe to merge as-is. Merging stays human-only.


结构化八问

  1. 是什么问题:side-lane 请求(dsh title-gen / auto-review / single-shot)是尽力而为的工具调用,却走了 live continuation refetch,导致 pipe 的 degenerate-turn gate([BUG] In some cases, with Codex's auto model + DeepSeek, it will suddenly terminate automatically. #732/workbuddy报错Empty stream: upstream gateway sent only placeholder chunks without any model output (chunks=0, bytes=0) #821 重试 + Plugin passthrough leaves the client an empty turn when the model echoes a render tag #870 带内错误)对它们生效——一个只返回 reasoning(effort=max 下无可见文本)的 title 请求被重发(工具调用重复计费),第二次仍空时客户端收到带内 stream 错误,DSH 把它写进了会话标题。
  2. 什么原因导致的:非注入流式分支没有区分 side-lane 与主车道,对 sidePassthrough 请求也传了 live makeContinuationRefetch。根因是分支在决定是否传续传 refetch 时没有按车道区分,而非 gate 本身有 bug。
  3. 影响范围与严重程度:影响所有返回 degenerate(无可见文本)响应的 side-lane 请求(dsh title-gen / auto-review / single-shot)。严重度 p2:工具调用被重复计费(成本)+ 客户端收到带内 stream 错误并被 DSH 写进会话标题(用户可见的标题损坏)。不是核心压缩故障,是 dsh title 面的用户可见缺陷。
  4. 怎么修复的:非注入流式分支对 sidePassthrough 请求传 refetch=undefined。refetch=undefined 会关掉 pipe 的整个 degenerate gate(重试 + Plugin passthrough leaves the client an empty turn when the model echoes a render tag #870)以及 cut 重试;非 side-lane 路径的三元对它是 no-op,gate 保持不变。
  5. 是否有回归问题:发现并修复了一处——两个 Provider 429 (concurrency-style limit): turn re-driven every few seconds for minutes, keeps the account pinned at the limit #4204 测试用 side-lane degenerate 轮作为触发续传 refetch + 429 作用域的载体,[bug] dsh title-gen sidecar misidentified as a degraded turn: 15/27 empty responses, 11 #870 in-band errors (0.1.213, ch | [bug] dsh title-gen sidecar 被误判为退化轮:15/27 次判空、11 次 #870 in-band error(0.1.213, chat-completions) #6466 移除了 side-lane refetch 后这两个测试变红。已把两者的载体改为主车道(非 side)非注入请求(预算提到 200 以上),仍会触发续传 refetch,保住 Provider 429 (concurrency-style limit): turn re-driven every few seconds for minutes, keeps the account pinned at the limit #4204 429 作用域的 e2e 覆盖。除此之外无回归:非 side-lane 路径不变(由新 [bug] dsh title-gen sidecar misidentified as a degraded turn: 15/27 empty responses, 11 #870 in-band errors (0.1.213, ch | [bug] dsh title-gen sidecar 被误判为退化轮:15/27 次判空、11 次 #870 in-band error(0.1.213, chat-completions) #6466 对照测试 + 5 个相关套件验证)。
  6. 是否破坏缓存:否。改动只影响 side-lane 请求的 degenerate-turn gate(重试 + Plugin passthrough leaves the client an empty turn when the model echoes a render tag #870),不触碰缓存、重试游标、去重键或前缀缓存。被禁用的续传 refetch 是重试机制,不是缓存机制。
  7. 是否改了设计方向:否。这是非注入流式分支里的局部行为修复,没有架构变更。side-lane 仍是尽力而为的工具调用,现在正确地跳过 degenerate-turn gate——设计方向(side-lane = 尽力而为、不重试)反而被这次修复澄清/加强了。
  8. 是否引入了新的配置:否。改动是 src/server/relay.ts 里的一个代码级三元,没有新增 env、config key 或默认值。

收工判定:可合并。核心修复正确,我引入的 CI 回归已修复并推送(9bbadd8a51),新 head 上 12 个 CI 工作流全绿,typecheck 干净。PR 落后 master 50 个提交但无冲突、新 master 提交不触碰本 PR 文件,可原样合并(合并按惯例由人工执行)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

Status confirmation (the full review is the [bot] 🏷 comment above with the 查重 conclusion and 结构化八问 — no need to re-read it). Current state, verified live:

  • The CI regression I found (2 #4204 tests in tests/proxy-noinject-tag-strip.test.ts) is fixed and pushed as commit 9bbadd8a51.
  • All 12 CI workflows pass on the updated head 9bbadd8a51 (including the main CI test-shard workflow that was red on the first head); typecheck clean.
  • The PR is mergeable (no conflicts; the 50 new master commits don't touch any of its files).

Nothing further needed from me — merging stays human-only.

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

bug Something isn't working dsh p2 scope/wiring

Projects

None yet

1 participant