From 2f604339e02779d69a178f9c54884e164e98f568 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Sat, 7 Nov 2026 23:36:55 +0800 Subject: [PATCH 1/7] Make the empty-turn continuation retry opt-in and reword its nudge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a turn ends with no visible output (thinking-only stop or a bare render-tag echo), the proxy re-issues the request once with a continuation nudge — currently on by default, on every lane. Two changes: - New `degenerateRetry` switch, default OFF. Enable with `degenerateRetry: true` or env `BILI_DEGENERATE_RETRY=1`. When off, an empty terminal turn passes through to the client unchanged and one log line names the switch. Covers both the main loop lane and the plugin pipes (the two places the retry existed). - Neutral nudge wording: the old text assumed a tool call was imminent and invited the model to "state your final answer explicitly", which can bias it into wrapping up early. The new text just asks for the turn's actual response. Retries that recover an upstream cut by re-sending the SAME body (no nudge) are unchanged and stay always-on. --- src/config.ts | 19 ++- src/degenerate-retry.ts | 9 +- src/degenerate-turn.ts | 3 +- src/loop/core.ts | 29 +++- src/plugin.ts | 24 +++- src/server/relay.ts | 28 ++-- tests/cache-proof.test.ts | 3 + tests/degenerate-retry-opt-in.test.ts | 197 ++++++++++++++++++++++++++ tests/issue2303-draft-tail.test.ts | 3 +- tests/loop-degenerate-retry.test.ts | 5 +- tests/plugin-empty-turn-retry.test.ts | 2 +- website/config-reference/server.yaml | 11 ++ 12 files changed, 303 insertions(+), 30 deletions(-) create mode 100644 tests/degenerate-retry-opt-in.test.ts diff --git a/src/config.ts b/src/config.ts index e8c42325c5..7341c4af8b 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1078,6 +1078,18 @@ export type ProxyOptions = { * BILI_PERSONA_SPLIT=0 or `personaSplit: false` in the config file * (env wins). */ personaSplit?: boolean; + /** Opt-in degenerate-turn continuation retry on the agent-facing plugin and + * proxy chat lanes (#732/#821/#2303; default OFF): when a turn ends with + * zero visible output (reasoning-only silent stop, or output that is + * nothing but a render-tag echo), re-issue the agent's own request ONCE + * with a neutral continuation nudge appended; if the retry is also empty, + * the client gets an in-band #870 error instead of a silently empty turn. + * OFF by default: the nudge re-bills the full request, and on sessions + * already deep in degeneration the retry just degenerates again. The + * compress loop's internal retry is NOT governed by this switch (it + * heals the proxy's own fold requests and stays on). + * Enable with `degenerateRetry: true` or env BILI_DEGENERATE_RETRY=1. */ + degenerateRetry?: boolean; /** Opt-in fork block-adoption (#629, default off). ANONYMOUS clients * (prefix-affinity) that fork their history inherit the parent's * fully-present compression blocks instead of restarting at zero. @@ -1827,6 +1839,7 @@ export function loadOptions(env: NodeJS.ProcessEnv = process.env): ProxyOptions subagentSplit: (env.BILI_SUBAGENT_SPLIT ?? (fileConfig.subagentSplit === false ? "0" : "1")) !== "0", personaSplit: (env.BILI_PERSONA_SPLIT ?? (fileConfig.personaSplit === false ? "0" : "1")) !== "0", forkAdoption: (env.BILI_FORK_ADOPTION ?? (fileConfig.forkAdoption === true ? "1" : "0")) !== "0", + degenerateRetry: (env.BILI_DEGENERATE_RETRY ?? (fileConfig.degenerateRetry === true ? "1" : "0")) !== "0", affinitySimhash: (env.BILI_AFFINITY_SIMHASH ?? (fileConfig.affinitySimhash === false ? "0" : "1")) !== "0", resumeInheritance: (env.BILI_RESUME_INHERITANCE ?? (fileConfig.resumeInheritance === false ? "0" : "1")) !== "0", chainContentDetection: (env.BILI_CHAIN_CONTENT ?? (fileConfig.chainContentDetection === true ? "1" : "0")) !== "0", @@ -2098,6 +2111,10 @@ type FileConfig = { * BILI_CHAIN_STAMP=1 wins over the file). Independent of * chainContentDetection. */ chainEgressStamp?: boolean; + /** #732/#821/#2303 opt-in: re-issue a zero-output terminal turn once with + * a continuation nudge on the plugin/proxy lanes. Default false; env + * BILI_DEGENERATE_RETRY=1 or config `degenerateRetry: true` enables. */ + degenerateRetry?: boolean; /** Set `true` to enable the sticky head-system anchor (#1085, default * OFF; env BILI_STABLE_SYSTEM_ANCHOR wins). */ stableSystemAnchor?: boolean; @@ -2528,7 +2545,7 @@ const KNOWN_TOP_LEVEL_KEYS = new Set([ "upstreamProxy", "upstreamProxyMode", "logFile", "compress", "promptCache", "mitm", "maskHosts", "subagentSplit", "personaSplit", "forkAdoption", "affinitySimhash", "resumeInheritance", - "chainContentDetection", "chainEgressStamp", "stableSystemAnchor", + "chainContentDetection", "chainEgressStamp", "stableSystemAnchor", "degenerateRetry", "rollout", "dsh", "compat", "imageBilling", "imageTokenCap", "claude", "native", "resign", diff --git a/src/degenerate-retry.ts b/src/degenerate-retry.ts index 47387df31f..a0ff14996f 100644 --- a/src/degenerate-retry.ts +++ b/src/degenerate-retry.ts @@ -39,9 +39,14 @@ function releaseThrottleErrorReader(reader: ReadableStreamDefaultReader => { - if (refetch === undefined || truncationRetried) return false; // #2303: a terminal turn whose visible prose ends with a compression-draft // closing tag and no tool call is non-converged even though it has visible // text — the model wrote a handoff/compression draft in prose instead of @@ -2992,6 +2991,17 @@ export async function pipePluginChatWithStrip( // retry byte-for-byte, so a delivered answer is never duplicated. const answerChars = answerProse.trim().length; if (!stalledTail && (answerChars > 0 || sawToolUse)) return false; + if (refetch === undefined) { + // The continuation retry is not armed on this lane (degenerateRetry + // default-off, or a plain pass-through caller): the empty turn passes + // through unchanged. Leave a trace so "the model replied nothing" is + // diagnosable from the log instead of reading as an idle session. + if (reason !== undefined && CLEAN_TURN_REASONS.has(reason)) { + log?.("[plugin] degenerate terminal turn (no visible output); continuation retry not armed on this lane — pass through unchanged (enable with degenerateRetry: true / BILI_DEGENERATE_RETRY=1)"); + } + return false; + } + if (truncationRetried) return false; if (reason === undefined || !CLEAN_TURN_REASONS.has(reason)) { if (!sawToolUse && !stalledTail && answerChars === 0) log?.(`[plugin] degenerate terminal turn not retried (finish ${reason ?? "none"} is not a clean stop): visibleTextChars=${visibleTextChars}, releasedMarkupChars=${releasedMarkupChars} (#2756)`); return false; @@ -4709,8 +4719,6 @@ export async function pipePluginResponsesWithStrip( * Returns true when the retry stream took over, in which case the caller * drops the held done-family events AND the completion it came from. */ const retryEmptyTurn = async (status: string | undefined): Promise => { - // truncationRetried: one re-issue per request, total — see the chat-pipe twin. - if (degenerateRetried || truncationRetried || refetch === undefined) return false; // #2303: same shape as the chat-pipe twin — visible prose ending in a // compression-draft closing tag with no function call is non-converged. // #2612: except when the request itself demands that shape (client @@ -4728,6 +4736,16 @@ export async function pipePluginResponsesWithStrip( // Real answer text still refuses the retry byte-for-byte. const answerChars = answerProse.trim().length; if (!stalledTail && (answerChars > 0 || sawFunctionCall)) return false; + if (refetch === undefined) { + // Same as the chat-pipe twin: retry not armed on this lane — leave + // a trace, then pass the empty turn through unchanged. + if (status === "completed") { + log?.("[plugin] degenerate terminal turn (no visible output); continuation retry not armed on this lane — pass through unchanged (enable with degenerateRetry: true / BILI_DEGENERATE_RETRY=1)"); + } + return false; + } + // truncationRetried: one re-issue per request, total — see the chat-pipe twin. + if (degenerateRetried || truncationRetried) return false; if (status !== "completed") { if (!sawFunctionCall && !stalledTail && answerChars === 0) log?.(`[plugin] degenerate terminal turn not retried (status ${status ?? "none"} is not completed): visibleTextChars=${visibleTextChars}, heldVisibleChars=${heldVisibleChars} (#2756)`); return false; diff --git a/src/server/relay.ts b/src/server/relay.ts index a9123e7253..56794e1a6e 100644 --- a/src/server/relay.ts +++ b/src/server/relay.ts @@ -2318,13 +2318,15 @@ const reply = prepared && !prepared.sidePassthrough ? createHandoffReply(prepare } else if (prepared.protocol === "responses") { // #732/#821 applies to this pipe too (#871): the agent's own // body, held here with its URL and headers, is re-issued once - // when the turn completes with nothing visible. + // when the turn completes with nothing visible. Opt-in via + // degenerateRetry (default OFF): without it the empty turn + // passes through unchanged and the pipe logs the not-armed note. await pipePluginResponsesWithStrip( pluginBody, res, prepared.session, (msg) => log("info", `[${prepared.session.id}] ${msg}`), - makeContinuationRefetch({ + opts.degenerateRetry === true ? makeContinuationRefetch({ protocol: "responses", body, model: throttleModel ?? prepared.google?.model, @@ -2335,7 +2337,7 @@ const reply = prepared && !prepared.sidePassthrough ? createHandoffReply(prepare signal: clientAbort.signal, log, label: prepared.session.id, - }), + }) : undefined, targetOrigin, absorbInstructed, wireBodyText, @@ -2347,14 +2349,14 @@ const reply = prepared && !prepared.sidePassthrough ? createHandoffReply(prepare // #732/#821: the plugin pipe re-issues the agent's own body // once when a turn ends with nothing visible (the render-tag // echo case) — it holds the URL and headers, this is where - // they live. + // they live. Opt-in via degenerateRetry (default OFF). await pipePluginChatWithStrip( pluginBody, res, prepared.protocol, prepared.session, (msg) => log("info", `[${prepared.session.id}] ${msg}`), - makeContinuationRefetch({ + opts.degenerateRetry === true ? makeContinuationRefetch({ protocol: prepared.protocol, body, model: throttleModel ?? prepared.google?.model, @@ -2365,7 +2367,7 @@ const reply = prepared && !prepared.sidePassthrough ? createHandoffReply(prepare signal: clientAbort.signal, log, label: prepared.session.id, - }), + }) : undefined, targetOrigin, absorbInstructed, wireBodyText, @@ -2499,7 +2501,7 @@ const reply = prepared && !prepared.sidePassthrough ? createHandoffReply(prepare res, undefined, tagLog, - makeContinuationRefetch({ + opts.degenerateRetry === true ? makeContinuationRefetch({ protocol: "responses", body, model: throttleModel ?? prepared.google?.model, @@ -2510,7 +2512,7 @@ const reply = prepared && !prepared.sidePassthrough ? createHandoffReply(prepare signal: clientAbort.signal, log, label: prepared.session.id, - }), + }) : undefined, undefined, undefined, undefined, @@ -2552,7 +2554,7 @@ const reply = prepared && !prepared.sidePassthrough ? createHandoffReply(prepare res, undefined, tagLog, - makeContinuationRefetch({ + opts.degenerateRetry === true ? makeContinuationRefetch({ protocol: "responses", body, model: throttleModel ?? p.google?.model, @@ -2563,7 +2565,7 @@ const reply = prepared && !prepared.sidePassthrough ? createHandoffReply(prepare signal: clientAbort.signal, log, label: p.session.id, - }), + }) : undefined, undefined, undefined, undefined, @@ -2578,7 +2580,7 @@ const reply = prepared && !prepared.sidePassthrough ? createHandoffReply(prepare p.protocol, undefined, tagLog, - makeContinuationRefetch({ + opts.degenerateRetry === true ? makeContinuationRefetch({ protocol: p.protocol, body, model: throttleModel ?? p.google?.model, @@ -2590,7 +2592,7 @@ const reply = prepared && !prepared.sidePassthrough ? createHandoffReply(prepare signal: clientAbort.signal, log, label: p.session.id, - }), + }) : undefined, undefined, undefined, undefined, @@ -2768,7 +2770,7 @@ const reply = prepared && !prepared.sidePassthrough ? createHandoffReply(prepare const loopBillingUpstream = route?.rewrittenUrl ?? (/^https?:\/\//i.test(req.url ?? "") ? req.url ?? undefined : opts.upstream); const loop = runCompressLoop( responseBody, - { core, config, messages: prepared.processedMessages.length > 0 ? prepared.processedMessages : prepared.originalMessages, compressMessages: prepared.originalMessages, session: prepared.session, reply, log: ctx.log, proxyUrl, skippedProxy, upstreamOrigin: targetOrigin, protocol: prepared.protocol, textProtocol, debug: opts.debug, refreshFolded, separatorSlots: () => loopSeparatorSlots, visibilityMarkers, dumpSse: loopDumpDir ? (name, stream) => dumpStreamToFile(stream, loopDumpDir, name) : undefined, imageLearn: { host: upstreamHost(loopBillingUpstream), fp: `${imageBillingFor(opts, loopBillingUpstream)}:${imageTokenCapFor(opts, loopBillingUpstream)}` } }, + { core, config, degenerateRetry: opts.degenerateRetry === true, messages: prepared.processedMessages.length > 0 ? prepared.processedMessages : prepared.originalMessages, compressMessages: prepared.originalMessages, session: prepared.session, reply, log: ctx.log, proxyUrl, skippedProxy, upstreamOrigin: targetOrigin, protocol: prepared.protocol, textProtocol, debug: opts.debug, refreshFolded, separatorSlots: () => loopSeparatorSlots, visibilityMarkers, dumpSse: loopDumpDir ? (name, stream) => dumpStreamToFile(stream, loopDumpDir, name) : undefined, imageLearn: { host: upstreamHost(loopBillingUpstream), fp: `${imageBillingFor(opts, loopBillingUpstream)}:${imageTokenCapFor(opts, loopBillingUpstream)}` } }, parsedReq, // #3280: egress goes out enveloped via wireTransform, so every // round-2+ response comes back enveloped too — unwrap at the loop's diff --git a/tests/cache-proof.test.ts b/tests/cache-proof.test.ts index 2ce716282f..63ad3e8890 100644 --- a/tests/cache-proof.test.ts +++ b/tests/cache-proof.test.ts @@ -766,6 +766,9 @@ function proofProxyOptions(upstreamPort: number, ctx: number, injectTool: boolea modelContextLimit: ctx, kernelConfig: defaultConfig(ctx), compress: { injectTool, injectNudge: true }, + // #732/#821 degenerate-refetch proofs below rely on the continuation + // retry, which is opt-in (degenerateRetry, default OFF). + degenerateRetry: true, promptCache: { routing: "auto" }, sessionHeader: "x-acp-session", log: false, diff --git a/tests/degenerate-retry-opt-in.test.ts b/tests/degenerate-retry-opt-in.test.ts new file mode 100644 index 0000000000..eb3c44001d --- /dev/null +++ b/tests/degenerate-retry-opt-in.test.ts @@ -0,0 +1,197 @@ +import assert from "node:assert"; +import http from "node:http"; +import { once } from "node:events"; +import path from "node:path"; +import { mkdtempSync } from "node:fs"; +import { tmpdir } from "node:os"; +import test from "node:test"; + +process.env.NODE_ENV = "test"; + +// Hermetic state dir per repo convention: without it this suite's writes land +// in the machine-global state and cross-contaminate parallel suites. +const xdgRoot = mkdtempSync(path.join(tmpdir(), "bc-degenerate-retry-opt-in-")); +process.env.XDG_STATE_HOME = path.join(xdgRoot, "state"); +process.env.XDG_CACHE_HOME = path.join(xdgRoot, "cache"); +process.env.XDG_DATA_HOME = path.join(xdgRoot, "data"); +process.env.XDG_CONFIG_HOME = path.join(xdgRoot, "config"); + +const { defaultConfig } = await import("acp-kernel"); +const { startServer } = await import("../src/server.ts"); +type ProxyOptions = import("../src/config.ts").ProxyOptions; +const { SessionStore, _setStoreForTest } = await import("../src/persist.ts"); +const { _setForTest: setRegistryForTest } = await import("../src/registry.ts"); +const { _resetSessionsForTest } = await import("../src/session.ts"); +const { DEGENERATE_RETRY_NUDGE } = await import("../src/degenerate-retry.ts"); + +/** A degenerate anthropic turn: a thinking block and a clean end_turn terminal, + * zero answer text — the #732/#821 silent-stop shape. */ +const degenerateTurn = (): string[] => [ + `event: message_start\n` + + `data: ${JSON.stringify({ type: "message_start", message: { id: "msg_deg", type: "message", role: "assistant", model: "claude-test", content: [], stop_reason: null } })}\n\n`, + `event: content_block_start\n` + + `data: ${JSON.stringify({ type: "content_block_start", index: 0, content_block: { type: "thinking", thinking: "" } })}\n\n`, + `event: content_block_delta\n` + + `data: ${JSON.stringify({ type: "content_block_delta", index: 0, delta: { type: "thinking_delta", thinking: "weighing the request silently" } })}\n\n`, + `event: content_block_stop\n` + + `data: ${JSON.stringify({ type: "content_block_stop", index: 0 })}\n\n`, + `event: message_delta\n` + + `data: ${JSON.stringify({ type: "message_delta", delta: { stop_reason: "end_turn", stop_sequence: null }, usage: { output_tokens: 12 } })}\n\n`, + `event: message_stop\n` + + `data: ${JSON.stringify({ type: "message_stop" })}\n\n`, +]; + +/** A healthy anthropic turn with one text block. */ +const goodTurn = (): string[] => [ + `event: message_start\n` + + `data: ${JSON.stringify({ type: "message_start", message: { id: "msg_good", type: "message", role: "assistant", model: "claude-test", content: [], stop_reason: null } })}\n\n`, + `event: content_block_start\n` + + `data: ${JSON.stringify({ type: "content_block_start", index: 0, content_block: { type: "text", text: "" } })}\n\n`, + `event: content_block_delta\n` + + `data: ${JSON.stringify({ type: "content_block_delta", index: 0, delta: { type: "text_delta", text: "The actual answer arrives now." } })}\n\n`, + `event: content_block_stop\n` + + `data: ${JSON.stringify({ type: "content_block_stop", index: 0 })}\n\n`, + `event: message_delta\n` + + `data: ${JSON.stringify({ type: "message_delta", delta: { stop_reason: "end_turn", stop_sequence: null }, usage: { output_tokens: 9 } })}\n\n`, + `event: message_stop\n` + + `data: ${JSON.stringify({ type: "message_stop" })}\n\n`, +]; + +interface MockUpstream { + port: number; + /** Every POST body received, in order — the retry must show up here. */ + bodies: string[]; + close(): Promise; +} + +/** Anthropic-wire mock: the FIRST request degenerates (thinking-only clean + * stop); every later request answers with text. */ +async function startMockUpstream(): Promise { + const bodies: string[] = []; + const server = http.createServer((req, res) => { + const chunks: Buffer[] = []; + req.on("data", (c: Buffer) => chunks.push(c)); + req.on("end", () => { + if (req.method !== "POST") { + res.writeHead(404, { "content-type": "application/json" }); + res.end(JSON.stringify({ error: { message: "mock upstream: unsupported" } })); + return; + } + bodies.push(Buffer.concat(chunks).toString("utf8")); + res.writeHead(200, { "content-type": "text/event-stream", "cache-control": "no-cache" }); + res.end((bodies.length === 1 ? degenerateTurn() : goodTurn()).join("")); + }); + }); + server.listen(0, "127.0.0.1"); + await once(server, "listening"); + return { + port: (server.address() as { port: number }).port, + bodies, + close: () => new Promise((resolve, reject) => server.close((e) => (e ? reject(e) : resolve()))), + }; +} + +interface Harness { + proxyPort: number; + upstream: MockUpstream; + close(): Promise; +} + +async function startHarness(degenerateRetry: boolean): Promise { + const upstream = await startMockUpstream(); + _resetSessionsForTest(); + _setStoreForTest(new SessionStore({ enabled: false })); + setRegistryForTest({}); + const routes: ProxyOptions["routes"] = {}; + routes[`http://127.0.0.1:${upstream.port}`] = { models: { "claude-test": { context: 100_000 } } }; + const proxy = await startServer({ + port: 0, + host: "127.0.0.1", + upstream: "http://127.0.0.1", + routes, + modelContextLimit: 100_000, + kernelConfig: defaultConfig(100_000), + compress: { injectTool: true, injectNudge: true }, + promptCache: { routing: "auto" }, + log: false, + sessionHeader: "x-acp-session", + debug: false, + passthrough: false, + autoUpdate: false, + mitm: { enabled: false, domains: [] }, + degenerateRetry, + compat: { roles: {} }, streamErrorShape: "protocol", passthroughSource: null, autoRestartOnUpdate: false, updateTag: "latest", advisoryCheck: false, releaseNotesCheck: false, + }); + await once(proxy, "listening"); + return { + proxyPort: (proxy.address() as { port: number }).port, + upstream, + close: async () => { + proxy.close(); + proxy.closeIdleConnections?.(); + await once(proxy, "close"); + await upstream.close(); + }, + }; +} + +const anthropicBody = (): Record => ({ + model: "claude-test", + stream: true, + max_tokens: 256, + messages: [{ role: "user", content: "What is the answer?" }], +}); + +async function streamOnce(h: Harness): Promise { + const resp = await fetch(`http://127.0.0.1:${h.proxyPort}/bili/http://127.0.0.1:${h.upstream.port}/v1/messages`, { + method: "POST", + headers: { "content-type": "application/json", "x-acp-session": "s-degen-optin", "x-api-key": "test", "anthropic-version": "2023-06-01" }, + body: JSON.stringify(anthropicBody()), + }); + if (resp.status !== 200) throw new Error(`proxy returned ${resp.status}: ${await resp.text()}`); + assert.match(resp.headers.get("content-type") ?? "", /text\/event-stream/); + const chunks: Buffer[] = []; + for await (const c of (resp.body ?? {} as AsyncIterable)) chunks.push(c as Buffer); + return Buffer.concat(chunks).toString("utf8"); +} + +test("degenerateRetry default OFF: a zero-output turn passes through with NO re-issue", async () => { + const h = await startHarness(false); + try { + const out = await streamOnce(h); + // Exactly one upstream request: the degenerate retry must NOT fire. + assert.equal(h.upstream.bodies.length, 1, `expected no re-issue, got ${h.upstream.bodies.length} upstream requests`); + // The client receives the empty-but-completed turn verbatim: a + // thinking block, a clean message_stop, zero answer text, and no + // in-band #870 error (that error belongs to a FAILED retry). + assert.match(out, /message_stop/); + assert.doesNotMatch(out, /text_delta/); + assert.doesNotMatch(out, /degenerated again/); + // No nudge ever hit the wire. + assert.ok(!h.upstream.bodies[0]!.includes(DEGENERATE_RETRY_NUDGE), "the nudge must not be injected when the retry is off"); + } finally { + await h.close(); + } +}); + +test("degenerateRetry: true — the same turn re-issues once with the neutral nudge and stitches the answer", async () => { + const h = await startHarness(true); + try { + const out = await streamOnce(h); + // The degenerate first attempt + exactly one re-issue. + assert.equal(h.upstream.bodies.length, 2, `expected one re-issue, got ${h.upstream.bodies.length} upstream requests`); + // The re-issued body carries the continuation nudge appended to the + // last user turn (appendTrailingUserText merge), and it is the NEUTRAL + // wording — no "final answer" push. + const retryBody = h.upstream.bodies[1]!; + assert.ok(retryBody.includes(DEGENERATE_RETRY_NUDGE), "retry body must carry DEGENERATE_RETRY_NUDGE"); + assert.ok(!retryBody.includes("state your final answer"), "nudge wording must stay neutral"); + // The client sees the retry's answer text stitched in, and no error + // frame. (The loop lane forwards the first attempt's thinking framing + // before the retry, so a second message_start pair is expected here.) + assert.match(out, /The actual answer arrives now\./); + assert.doesNotMatch(out, /degenerated again/); + } finally { + await h.close(); + } +}); diff --git a/tests/issue2303-draft-tail.test.ts b/tests/issue2303-draft-tail.test.ts index c9c6132db2..a7404710f8 100644 --- a/tests/issue2303-draft-tail.test.ts +++ b/tests/issue2303-draft-tail.test.ts @@ -297,6 +297,7 @@ function makeCtx(id: string, protocol: "responses" | "openai" = "openai") { return { core: createCore(), config: { modelContextLimit: 200000 } as Config, + degenerateRetry: true, messages: [] as CoreMessage[], session: { id, @@ -372,7 +373,7 @@ test("#2303 loop: draft-tail terminal turn → one invisible retry with the cont assert.equal(fetchCalls, 1, "re-request + exactly one draft-tail auto-retry"); assert.ok(bodies.length >= 1, "retry request observed"); assert.ok( - bodies[0]!.includes("ended without a tool call"), + bodies[0]!.includes("produced no visible output"), "the retry body carries the ephemeral continuation nudge", ); // Single-line fragments: inside the SSE frames the draft's newlines are diff --git a/tests/loop-degenerate-retry.test.ts b/tests/loop-degenerate-retry.test.ts index 5f340a634d..8449b6c7de 100644 --- a/tests/loop-degenerate-retry.test.ts +++ b/tests/loop-degenerate-retry.test.ts @@ -21,6 +21,7 @@ function makeCtx(id: string, protocol: "responses" | "openai" = "responses") { return { core: createCore(), config: { modelContextLimit: 200000 } as Config, + degenerateRetry: true, messages: [] as CoreMessage[], session: { id, @@ -104,7 +105,7 @@ test("#732 D1: degenerate post-compress turn → one invisible retry with a cont assert.equal(fetchCalls, 2, "re-request + exactly one degenerate auto-retry"); assert.ok(bodies.length >= 2, "both requests observed"); assert.ok( - bodies[1].includes("ended without a tool call"), + bodies[1].includes("produced no visible output"), "the retry body carries the ephemeral continuation nudge", ); assert.ok(out.includes("continued after nudge"), "the retried turn's content was delivered to the client"); @@ -176,7 +177,7 @@ test("#821 O1: openai-wire round-1 thinking-only turn → one auto-retry appende const { out, fetchCalls, bodies } = await drainOpenai(OPENAI_THINKING_ONLY, [OPENAI_GOOD], "deg-o1"); assert.equal(fetchCalls, 1, "exactly one degenerate auto-retry fired"); assert.ok( - bodies[0].includes("ended without a tool call"), + bodies[0].includes("produced no visible output"), "the retry body carries the ephemeral continuation nudge", ); assert.ok(out.includes("the context looks small"), "the thinking prefix was streamed to the client"); diff --git a/tests/plugin-empty-turn-retry.test.ts b/tests/plugin-empty-turn-retry.test.ts index cf3625956a..217f8a3731 100644 --- a/tests/plugin-empty-turn-retry.test.ts +++ b/tests/plugin-empty-turn-retry.test.ts @@ -238,7 +238,7 @@ test("the continuation retry body carries the nudge as a trailing user turn", () assert.equal(merged.messages[0]!.role, "user"); assert.ok(merged.messages[0]!.content.startsWith("hi"), "the original text is preserved"); assert.ok( - merged.messages[0]!.content.includes("ended without a tool call"), + merged.messages[0]!.content.includes("produced no visible output"), `the nudge text is appended, got: ${merged.messages[0]!.content}`, ); diff --git a/website/config-reference/server.yaml b/website/config-reference/server.yaml index d05c9e7e50..6e166cc50a 100644 --- a/website/config-reference/server.yaml +++ b/website/config-reference/server.yaml @@ -302,6 +302,17 @@ entries: desc_ja: "匿名フォークは、フォークされたリクエストにソースコンテンツが完全に存在する親の圧縮ブロックを継承します。" site_en: "forkAdoption — adopt anonymous forks into their parent session (off by default)." site_zh: "forkAdoption —— 匿名 fork 会话并入父会话(默认关)。" + - key: degenerateRetry + type: boolean + default: "false" + env: BILI_DEGENERATE_RETRY + group: behavior + id: tt.degen + site_group: beh + desc_en: "Opt-in degenerate-turn continuation retry on the agent-facing plugin/proxy lanes (#732/#821/#2303): when a turn ends with zero visible output, re-issue the agent's own request once with a neutral continuation nudge appended; a second empty retry surfaces an in-band #870 error. The compress loop's internal retry is unaffected. Enable with degenerateRetry: true or env BILI_DEGENERATE_RETRY=1." + desc_zh: "代理对外车道上的退化轮续传重试(#732/#821/#2303,默认关):一轮以零可见输出结束时,把客户端自己的请求附加中性续传提示后重发一次;重试仍为空则以带内 #870 错误收尾。压缩循环内部的重试不受此开关影响。用 degenerateRetry: true 或环境变量 BILI_DEGENERATE_RETRY=1 开启。" + site_en: "degenerateRetry — one-shot continuation retry for zero-output turns (off by default; BILI_DEGENERATE_RETRY=1 to enable)." + site_zh: "degenerateRetry —— 零输出轮的一次性续传重试(默认关;BILI_DEGENERATE_RETRY=1 开启)。" - key: autoModeForge.enabled type: boolean default: "true" From a6481ce63f7472e14cb43654ae59c911e6126783 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Sat, 7 Nov 2026 23:53:46 +0800 Subject: [PATCH 2/7] Fix PR gates: regenerate config docs, register BILI_DEGENERATE_RETRY in LIFECYCLE.md --- docs/configuration.md | 2 ++ docs/configuration.zh-CN.md | 2 ++ docs/lifecycle.md | 1 + website/docs/index.html | 1 + website/main.js | 2 ++ 5 files changed, 8 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index 6eaf046056..2f97b26c06 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -113,6 +113,7 @@ This index is generated from `website/config-reference/*.yaml` — edit the seed | `subagentSplit` | boolean | true | BILI_SUBAGENT_SPLIT | Claude Code subagents get their own session namespace (\|sub:) instead of queueing behind the main session. Anthropic-wire only — on the Responses wire this switch is a no-op (see the `subagentSplit` / BOTH-mechanisms scope note). | | `personaSplit` | boolean | true | BILI_PERSONA_SPLIT | Split the Responses-wire lane keyed by the instructions fingerprint (Claude Code over /v1/responses; Codex root threads / older builds) when the instructions text changes AND the incoming history does not continue the tracked chain (default on). Opt out with env BILI_PERSONA_SPLIT=0 or personaSplit: false (env wins). | | `forkAdoption` | boolean | false | BILI_FORK_ADOPTION | Anonymous forks inherit the parent's compression blocks whose source content is fully present in the forked request. | +| `degenerateRetry` | boolean | false | BILI_DEGENERATE_RETRY | Opt-in degenerate-turn continuation retry on the agent-facing plugin/proxy lanes (#732/#821/#2303): when a turn ends with zero visible output, re-issue the agent's own request once with a neutral continuation nudge appended; a second empty retry surfaces an in-band #870 error. The compress loop's internal retry is unaffected. Enable with degenerateRetry: true or env BILI_DEGENERATE_RETRY=1. | | `autoModeForge.enabled` | boolean | true | BILI_AUTO_MODE_FORGE | Answer Claude Code auto-mode safety-classifier calls locally with a forged allow verdict instead of forwarding them upstream (#2740): zero egress, zero billing for that lane; every forged verdict is audit-logged and the session carries a notice badge. false / env 0 restores pure passthrough for users who pay for real verdicts. | | `affinitySimhash` | boolean | true | BILI_AFFINITY_SIMHASH | Simhash chain-alignment adoption for anonymous clients (#2265): a client-side pervasive decorative rewrite (e.g. Trae re-stamping model tags on every assistant message) re-attaches the existing session with its compression state instead of minting fresh and re-folding from zero. | | `resumeInheritance` | boolean | true | BILI_RESUME_INHERITANCE | Identified clients resuming under a new session id inherit the parent's ref assignments and fully-present compression blocks. | @@ -1969,6 +1970,7 @@ File keys resolve only when the matching env var is unset. Defaults in parenthes | `BILI_CODEX_COMPACT` | `codexCompact` | "intercept" | | `BILI_DECODED_BODY_BYTES` | `network.decodedBodyBytes` | 10737418240 | | `BILI_DECOMPRESS_TMP_CAP` | `decompressTmpCap` | 50 | +| `BILI_DEGENERATE_RETRY` | `degenerateRetry` | false | | `BILI_DSH_AUTHORED_COMPACTION` | `dsh.authoredCompaction` | true (on, #3901 flip) | | `BILI_DSH_CONTEXT_TAB` | `dsh.contextTab` | true | | `BILI_DUMP_4XX` | `diagnostics.dump4xx` | false | diff --git a/docs/configuration.zh-CN.md b/docs/configuration.zh-CN.md index 6209c06540..dd6e81ebcf 100644 --- a/docs/configuration.zh-CN.md +++ b/docs/configuration.zh-CN.md @@ -113,6 +113,7 @@ | `subagentSplit` | boolean | true | BILI_SUBAGENT_SPLIT | Claude 子代理拥有独立会话命名空间(\|sub:),不再排队在主会话锁后。仅 anthropic 线路 —— Responses 线路上本开关无效(见 `subagentSplit` / BOTH-mechanisms 作用域说明)。 | | `personaSplit` | boolean | true | BILI_PERSONA_SPLIT | 当 instructions 文本变化且入站历史不连续时,把按 instructions 指纹分键的 Responses 车道(Claude Code over /v1/responses;Codex 根线程 / 旧版本构建)分叉出去(默认开)。用环境变量 BILI_PERSONA_SPLIT=0 或配置 personaSplit: false 关闭(环境变量优先)。 | | `forkAdoption` | boolean | false | BILI_FORK_ADOPTION | 匿名 fork 会话继承父会话中源内容完整存在于本次请求里的压缩块。 | +| `degenerateRetry` | boolean | false | BILI_DEGENERATE_RETRY | 代理对外车道上的退化轮续传重试(#732/#821/#2303,默认关):一轮以零可见输出结束时,把客户端自己的请求附加中性续传提示后重发一次;重试仍为空则以带内 #870 错误收尾。压缩循环内部的重试不受此开关影响。用 degenerateRetry: true 或环境变量 BILI_DEGENERATE_RETRY=1 开启。 | | `autoModeForge.enabled` | boolean | true | BILI_AUTO_MODE_FORGE | Claude Code auto mode 安全分类器请求由 bili 在本地代答放行判定,不再转发上游(#2740):该旁路零流出、零计费;每条代答写审计日志,会话带提示徽标。false / env 0 恢复纯透传(愿意付费要真判定的用户)。 | | `affinitySimhash` | boolean | true | BILI_AFFINITY_SIMHASH | 匿名客户端的 simhash 链对齐收养(#2265):客户端侧大面积装饰性改写(如 Trae 切模型后给每条 assistant 消息重打模型标签)时,重新挂回既有会话并保留压缩状态,而不是每次新铸会话、从零重折。 | | `resumeInheritance` | boolean | true | BILI_RESUME_INHERITANCE | 以新会话 id 恢复的已识别客户端继承父会话的引用编号与完整存在的压缩块。 | @@ -1946,6 +1947,7 @@ ACP 原生 agent(当前为 `pi` 扩展)会在每个进程内向代理上报 | `BILI_CODEX_COMPACT` | `codexCompact` | "intercept" | | `BILI_DECODED_BODY_BYTES` | `network.decodedBodyBytes` | 10737418240 | | `BILI_DECOMPRESS_TMP_CAP` | `decompressTmpCap` | 50 | +| `BILI_DEGENERATE_RETRY` | `degenerateRetry` | false | | `BILI_DSH_AUTHORED_COMPACTION` | `dsh.authoredCompaction` | true (on, #3901 flip) | | `BILI_DSH_CONTEXT_TAB` | `dsh.contextTab` | true | | `BILI_DUMP_4XX` | `diagnostics.dump4xx` | false | diff --git a/docs/lifecycle.md b/docs/lifecycle.md index 97c4400148..47c09bfd2e 100644 --- a/docs/lifecycle.md +++ b/docs/lifecycle.md @@ -47,6 +47,7 @@ | `BILI_CHAIN_STAMP` | egress stamp | stripped-middlebox 场景的出口戳(默认 off) | 同上 | 默认 off | | `BILI_STABLE_SYSTEM_ANCHOR` | stable-system-anchor 实验 | 每会话 system 锚点实验(默认 OFF) | 稳定性评估后转正或删 | opt-in(默认 OFF) | | `BILI_FORK_ADOPTION` | fork-adoption 特性 | fork 继承实验(opt-in;禁用时提示从零开始,fork-adoption.ts:300) | 稳定后转正或退役 | opt-in(默认 off) | +| `BILI_DEGENERATE_RETRY` | #5897 | 空轮续跑 opt-in:开启后轮次零可见输出时自动带中性续跑提示重发一次(loop 车道与 plugin 管道都受管;默认关 = 空轮原样透传,不重发不注入) | 空轮续跑行为定型后转正或退役 | opt-in(默认 off) | | `BILI_ALLOW_DSH_COMPACTION` | dsh compaction | dsh compaction opt-in(env 语义同 BILI_PERSIST 家族) | 转正后移 §2 | opt-in(`=1`) | | `BILI_SNAPSHOT_SHADOW` | #3756 | snapshot-render 影子观测:每个 armed turn 计算快照视图但**不使用**(出站仍走 legacy 路径),与实际发送对比记 per-session 计数(面板 + `snapshot-shadow` 诊断话题)——render 引擎在 rollout 翻转前用真实流量证明健康(dry-run-then-flip,同存储 #2815 shadow→#3818 full 纪律) | render 车道转正(rollout 100% 且影子计数归稳)后退役 | 默认 on(render lane 本身 rollout 0%,纯观测) | | `BILI_DSH_AUTHORED_COMPACTION` | #3733 | dsh 原生 compaction summarize 调用由 #1729 guard 拒绝改为**本地应答折叠快照**(零出账;dsh 记 checkpoint、会话文件收缩) | adoption 后按 #2028 模式转 file/web 开关,env 退役(file 键 `dsh.authoredCompaction` 已镜像) | 0.1.203 dogfood 站稳后默认 on;`=0` 回 #1729 拒绝路径 | diff --git a/website/docs/index.html b/website/docs/index.html index 4b1172324e..a7b1568581 100644 --- a/website/docs/index.html +++ b/website/docs/index.html @@ -285,6 +285,7 @@

Other top-level fields

  • subagentSplit — Claude subagents get their own session namespace (on by default).
  • personaSplit — Responses-wire instructions-fingerprint split (on by default; set false / BILI_PERSONA_SPLIT=0 to opt out).
  • forkAdoption — adopt anonymous forks into their parent session (off by default).
  • +
  • degenerateRetry — one-shot continuation retry for zero-output turns (off by default; BILI_DEGENERATE_RETRY=1 to enable).
  • autoModeForge.enabled — answer Claude Code auto-mode classifier calls locally with a forged allow verdict (on by default; BILI_AUTO_MODE_FORGE=0 = pure passthrough).
  • affinitySimhash — simhash chain-alignment re-attaches sessions after pervasive client rewrites (on by default).
  • resumeInheritance — inherited refs/blocks on resume (cc --resume) (on by default).
  • diff --git a/website/main.js b/website/main.js index 19461eee64..ccc1dea065 100644 --- a/website/main.js +++ b/website/main.js @@ -162,6 +162,7 @@ "tt.subagent": "subagentSplit — Claude subagents get their own session namespace (on by default).", "tt.persona": "personaSplit — Responses-wire instructions-fingerprint split (on by default; set false / BILI_PERSONA_SPLIT=0 to opt out).", "tt.fork": "forkAdoption — adopt anonymous forks into their parent session (off by default).", + "tt.degen": "degenerateRetry — one-shot continuation retry for zero-output turns (off by default; BILI_DEGENERATE_RETRY=1 to enable).", "tt.autoforge": "autoModeForge.enabled — answer Claude Code auto-mode classifier calls locally with a forged allow verdict (on by default; BILI_AUTO_MODE_FORGE=0 = pure passthrough).", "tt.simhash": "affinitySimhash — simhash chain-alignment re-attaches sessions after pervasive client rewrites (on by default).", "tt.resinherit": "resumeInheritance — inherited refs/blocks on resume (cc --resume) (on by default).", @@ -420,6 +421,7 @@ "tt.subagent": "subagentSplit —— Claude 子代理拥有独立会话命名空间(默认开)。", "tt.persona": "personaSplit —— Responses 线路 instructions 指纹分叉(默认开;false / BILI_PERSONA_SPLIT=0 关闭)。", "tt.fork": "forkAdoption —— 匿名 fork 会话并入父会话(默认关)。", + "tt.degen": "degenerateRetry —— 零输出轮的一次性续传重试(默认关;BILI_DEGENERATE_RETRY=1 开启)。", "tt.autoforge": "autoModeForge.enabled —— Claude Code auto mode 分类器请求本地代答放行判定(默认开;BILI_AUTO_MODE_FORGE=0 纯透传)。", "tt.simhash": "affinitySimhash —— 大面积客户端改写后按 simhash 链对齐重新挂回会话(默认开)。", "tt.resinherit": "resumeInheritance —— resume(cc --resume)继承引用与区块(默认开)。", From 6c519a806108c38e2fb850b656ad11ee604e66aa Mon Sep 17 00:00:00 2001 From: ci-check Date: Sun, 8 Nov 2026 01:43:38 +0800 Subject: [PATCH 3/7] test: arm the opt-in degenerateRetry switch in the two suites that assert continuation-retry behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The opt-in change made the empty-turn (#732/#821) and draft-tail (#2303) continuation retries default OFF and updated its own fixtures to arm the switch (cache-proof, issue2303-draft-tail, loop-degenerate-retry), but missed two suites that also drive those retries: - tests/issue2612-compaction-draft-tail.test.ts: the loop subtest asserting "the SAME reply IS still retried without the instruction" got 0 fetches instead of 1 (its sibling "NOT retried with instruction" passed vacuously). - tests/proxy-noinject-tag-strip.test.ts: both #4204 side-lane tests expect exactly one continuation refetch after a tag-only turn (hits 2, got 1). Arms degenerateRetry: true in each suite's shared fixture — the same pattern the opt-in commit used for its own test files. No product-code change: the default-off behavior for real users is untouched. --- tests/issue2612-compaction-draft-tail.test.ts | 4 ++++ tests/proxy-noinject-tag-strip.test.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tests/issue2612-compaction-draft-tail.test.ts b/tests/issue2612-compaction-draft-tail.test.ts index 0e86cf39a9..c6dce39ba8 100644 --- a/tests/issue2612-compaction-draft-tail.test.ts +++ b/tests/issue2612-compaction-draft-tail.test.ts @@ -202,6 +202,10 @@ function makeCtx(id: string, messages: CoreMessage[]) { return { core: createCore(), config: { modelContextLimit: 200000 } as Config, + // The loop subtests assert the draft-tail retry DECISION (#2612 guard + // vs #2303 protection); arm the opt-in switch (default OFF) so they + // exercise the guard instead of the default pass-through. + degenerateRetry: true, messages, session: { id, diff --git a/tests/proxy-noinject-tag-strip.test.ts b/tests/proxy-noinject-tag-strip.test.ts index 0cfffd55d8..dd798906c5 100644 --- a/tests/proxy-noinject-tag-strip.test.ts +++ b/tests/proxy-noinject-tag-strip.test.ts @@ -67,6 +67,10 @@ async function startHarness( routes: { [`http://127.0.0.1:${upstreamPort}`]: { models: { "claude-test": { context: 400_000 }, "gpt-test": { context: 400_000 } } } }, modelContextLimit: 400_000, kernelConfig: defaultConfig(400_000), + // The #4204 side-lane tests below rely on the empty-turn + // continuation refetch, which is opt-in (degenerateRetry, + // default OFF). + degenerateRetry: true, promptCache: { routing: "auto" }, compress, sessionHeader: "x-acp-session", From 406ebbf5a2aae497aee0505ea32f276354ff5fcc Mon Sep 17 00:00:00 2001 From: ci-check Date: Tue, 10 Nov 2026 23:56:14 +0800 Subject: [PATCH 4/7] test: align the #5986 whitespace-gate W1 assertion with the reworded nudge (#5897 rebase fallout) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Master's #5986 added the W1 subtest (reasoning + whitespace-only text) after this PR branched, asserting the pre-PR nudge wording 'ended without a tool call'. The PR rewords the nudge to 'produced no visible output' and updated its own copies of that assertion (D1/O1 in this same file); the W1 copy is updated here to match — mechanical rebase fallout, no behavior change. --- tests/loop-degenerate-retry.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/loop-degenerate-retry.test.ts b/tests/loop-degenerate-retry.test.ts index 8449b6c7de..6ca2e78d4a 100644 --- a/tests/loop-degenerate-retry.test.ts +++ b/tests/loop-degenerate-retry.test.ts @@ -217,7 +217,7 @@ test("#732-follow-up W1: reasoning + whitespace-only text + stop → the #732 re const { out, fetchCalls, bodies } = await drainOpenai(OPENAI_THINKING_WSPRIBE, [OPENAI_GOOD], "deg-w1"); assert.equal(fetchCalls, 1, "exactly one degenerate auto-retry fired despite the forwarded \"\\n\\n\""); assert.ok( - bodies[0].includes("ended without a tool call"), + bodies[0].includes("produced no visible output"), "the retry body carries the ephemeral continuation nudge", ); assert.ok(out.includes("let me check the logs"), "the thinking prefix was streamed to the client"); From 59d31d2296635db90d5d350a0d6bb66ba2e2a129 Mon Sep 17 00:00:00 2001 From: ci-check Date: Sun, 15 Nov 2026 09:21:51 +0800 Subject: [PATCH 5/7] docs: add missing desc_ja for degenerateRetry seed entry (docs-sync rebase fallout) Master's gen-config-docs now hard-requires desc_ja on every seed entry (to emit docs/configuration.ja.md); the degenerateRetry entry landed without it, so docs-sync fails on the rebased head. Add the Japanese description and regenerate the ja artifact. --- docs/configuration.ja.md | 2 ++ website/config-reference/server.yaml | 1 + 2 files changed, 3 insertions(+) diff --git a/docs/configuration.ja.md b/docs/configuration.ja.md index 215a6ffc3e..d4f9f613d6 100644 --- a/docs/configuration.ja.md +++ b/docs/configuration.ja.md @@ -110,6 +110,7 @@ | `subagentSplit` | boolean | true | BILI_SUBAGENT_SPLIT | Claude Code サブエージェントは、メインセッションのキューに並ぶ代わりに、独自のセッション名前空間(\|sub:)を取得します。Anthropic-wire 専用 — Responses wire ではこのスイッチは no-op です(`subagentSplit` / BOTH-mechanisms スコープ注記を参照)。 | | `personaSplit` | boolean | true | BILI_PERSONA_SPLIT | 指示テキストが変更され、かつ受信履歴が追跡中のチェーンを継続していない場合、指示フィンガープリントでキー付けされた Responses-wire レーンを分割します(Claude Code の /v1/responses 経由; Codex ルートスレッド / 旧ビルド)。デフォルトで有効。環境変数 BILI_PERSONA_SPLIT=0 または personaSplit: false で無効化可能(環境変数が優先)。 | | `forkAdoption` | boolean | false | BILI_FORK_ADOPTION | 匿名フォークは、フォークされたリクエストにソースコンテンツが完全に存在する親の圧縮ブロックを継承します。 | +| `degenerateRetry` | boolean | false | BILI_DEGENERATE_RETRY | エージェント向けプラグイン/プロキシレーンでの opt-in 退化ターン継続リトライ(#732/#821/#2303):ターンがゼロの可視出力で終わった場合、中立的な継続ナッジを付加してエージェント自身のリクエストを一度だけ再発行します。リトライ後も空だった場合はインバンドで #870 エラーで終了します。圧縮ループ内部のリトライは影響を受けません。degenerateRetry: true または環境変数 BILI_DEGENERATE_RETRY=1 で有効にします。 | | `autoModeForge.enabled` | boolean | true | BILI_AUTO_MODE_FORGE | Claude Code の自動モードのセーフティ分類器呼び出しを、上流へ転送する代わりに、偽造された許可判定でローカルに回答します(#2740):そのレーンでは送信ゼロ、課金ゼロ。すべての偽造判定は監査ログに記録され、セッションには通知バッジが付与されます。false / 環境変数 0 で、実際の判定料金を支払うユーザー向けに純粋なパススルーに戻ります。 | | `affinitySimhash` | boolean | true | BILI_AFFINITY_SIMHASH | 匿名クライアント向けの Simhash チェーン整合性採用(#2265):クライアント側の普遍的な装飾的書き換え(例:Trae がすべてのアシスタントメッセージにモデルタグを再スタンプする)が発生した場合、ゼロから新規発行して再折りたたむ代わりに、既存のセッションとその圧縮状態を再アタッチします。 | | `resumeInheritance` | boolean | true | BILI_RESUME_INHERITANCE | 新しいセッション ID で再開する識別済みクライアントは、親の ref 割り当てと完全に存在する圧縮ブロックを継承します。 | @@ -1956,6 +1957,7 @@ ACP ネイティブエージェント(現在は `pi` 拡張機能)は、プ | `BILI_CODEX_COMPACT` | `codexCompact` | "intercept" | | `BILI_DECODED_BODY_BYTES` | `network.decodedBodyBytes` | 10737418240 | | `BILI_DECOMPRESS_TMP_CAP` | `decompressTmpCap` | 50 | +| `BILI_DEGENERATE_RETRY` | `degenerateRetry` | false | | `BILI_DSH_AUTHORED_COMPACTION` | `dsh.authoredCompaction` | true (on, #3901 flip) | | `BILI_DSH_CONTEXT_TAB` | `dsh.contextTab` | true | | `BILI_DUMP_4XX` | `diagnostics.dump4xx` | false | diff --git a/website/config-reference/server.yaml b/website/config-reference/server.yaml index 6e166cc50a..ae63a04369 100644 --- a/website/config-reference/server.yaml +++ b/website/config-reference/server.yaml @@ -311,6 +311,7 @@ entries: site_group: beh desc_en: "Opt-in degenerate-turn continuation retry on the agent-facing plugin/proxy lanes (#732/#821/#2303): when a turn ends with zero visible output, re-issue the agent's own request once with a neutral continuation nudge appended; a second empty retry surfaces an in-band #870 error. The compress loop's internal retry is unaffected. Enable with degenerateRetry: true or env BILI_DEGENERATE_RETRY=1." desc_zh: "代理对外车道上的退化轮续传重试(#732/#821/#2303,默认关):一轮以零可见输出结束时,把客户端自己的请求附加中性续传提示后重发一次;重试仍为空则以带内 #870 错误收尾。压缩循环内部的重试不受此开关影响。用 degenerateRetry: true 或环境变量 BILI_DEGENERATE_RETRY=1 开启。" + desc_ja: "エージェント向けプラグイン/プロキシレーンでの opt-in 退化ターン継続リトライ(#732/#821/#2303):ターンがゼロの可視出力で終わった場合、中立的な継続ナッジを付加してエージェント自身のリクエストを一度だけ再発行します。リトライ後も空だった場合はインバンドで #870 エラーで終了します。圧縮ループ内部のリトライは影響を受けません。degenerateRetry: true または環境変数 BILI_DEGENERATE_RETRY=1 で有効にします。" site_en: "degenerateRetry — one-shot continuation retry for zero-output turns (off by default; BILI_DEGENERATE_RETRY=1 to enable)." site_zh: "degenerateRetry —— 零输出轮的一次性续传重试(默认关;BILI_DEGENERATE_RETRY=1 开启)。" - key: autoModeForge.enabled From 1878a17cb7ac32de3117f2d4c2c98d4b24f525e8 Mon Sep 17 00:00:00 2001 From: ci-check Date: Sun, 15 Nov 2026 09:47:43 +0800 Subject: [PATCH 6/7] test: arm the opt-in degenerateRetry switch in the #3905 loop suite and align the nudge assertion The #3905 announcement-tail loop tests exercise the same one-shot continuation retry the PR made opt-in (degenerateRetry, default OFF) and reworded ("produced no visible output"). The suite's makeCtx never armed the switch, so the three retry-positive cases saw 0 re-issues, and the nudge assertion still checked the old wording. Arm the switch (matching the sibling loop-degenerate-retry suite) and update the assertion. --- tests/issue3905-announcement-tail.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/issue3905-announcement-tail.test.ts b/tests/issue3905-announcement-tail.test.ts index be0bf43b4c..10a3a5e61e 100644 --- a/tests/issue3905-announcement-tail.test.ts +++ b/tests/issue3905-announcement-tail.test.ts @@ -294,6 +294,7 @@ function makeCtx(id: string, protocol: "responses" | "openai" = "openai") { return { core: createCore(), config: { modelContextLimit: 200000 } as Config, + degenerateRetry: true, messages: [] as CoreMessage[], session: { id, @@ -360,7 +361,7 @@ async function drainOpenai(first: string, retries: string[], id: string): Promis test("#3905 loop: a bare announcement → one invisible retry with the continuation nudge", async () => { const { out, fetchCalls, bodies } = await drainOpenai(OPENAI_ANNOUNCE, [OPENAI_GOOD], "at-l1"); assert.equal(fetchCalls, 1, "exactly one announcement-tail auto-retry"); - assert.ok(bodies[0]!.includes("ended without a tool call"), "the retry carries the continuation nudge"); + assert.ok(bodies[0]!.includes("produced no visible output"), "the retry carries the continuation nudge"); assert.ok(out.includes(ANNOUNCE_STUB), "the stub itself reached the client (the host already rendered it)"); assert.ok(out.includes("continued after nudge"), "the retried turn's content was delivered"); }); From 87dd3131991cf16ee76a51e5298fba933a78ee4c Mon Sep 17 00:00:00 2001 From: review-worker Date: Sun, 15 Nov 2026 10:29:54 +0800 Subject: [PATCH 7/7] test: pin the not-armed (no refetch) pass-through branch of the empty-turn retry The opt-in switch makes the relay pass NO refetch when degenerateRetry is off (the default). That not-armed branch is distinct from the armed path whose refetch() returns null, and it had no direct test. Add the negative direction for both the chat and responses pipes: the empty turn passes through unchanged (one terminal, no tag leak) and leaves a 'continuation retry not armed' trace. #3617 gate discipline: both directions asserted. --- tests/plugin-empty-turn-retry.test.ts | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/plugin-empty-turn-retry.test.ts b/tests/plugin-empty-turn-retry.test.ts index 217f8a3731..e5a41eeb3e 100644 --- a/tests/plugin-empty-turn-retry.test.ts +++ b/tests/plugin-empty-turn-retry.test.ts @@ -215,6 +215,27 @@ test("plugin chat passes the empty turn through when the retry cannot be issued" } }); +// The opt-in switch (#5897) makes the relay pass NO refetch when degenerateRetry +// is off (the default). That not-armed branch is distinct from the armed path +// whose refetch() returns null (the test above): it must pass the empty turn +// through unchanged AND leave a trace, so "the model replied nothing" is +// diagnosable instead of reading as an idle session. +test("plugin chat passes the empty turn through unchanged when the retry is not armed (no refetch)", async () => { + const out: string[] = []; + const logs: string[] = []; + await pipePluginChatWithStrip( + streamOf(echoOnlyTurn()), makeRes(out), "openai", makeSession(), + (msg) => { logs.push(msg); }, + ); + const text = out.join(""); + assert.equal((text.match(/\[DONE\]/g) ?? []).length, 1, "one turn, one terminal, no re-issue"); + assert.ok(!text.includes("m00155"), "the echoed tag never leaks"); + assert.ok( + logs.some((l) => l.includes("continuation retry not armed")), + `the not-armed pass-through leaves a trace, got: ${JSON.stringify(logs)}`, + ); +}); + test("plugin chat (anthropic) lands the retry's content in a block after the client's own", async () => { const out: string[] = []; let calls = 0; @@ -320,6 +341,24 @@ test("plugin responses retries once when the turn's only text was a stripped ech assert.ok(text.includes('"item_id":"item_1"'), "the retry's deltas carry the item id the client already holds"); }); +// Responses-pipe twin of the chat not-armed test above: no refetch (degenerateRetry +// off) must pass the empty completed turn through unchanged and leave a trace. +test("plugin responses passes the empty turn through unchanged when the retry is not armed (no refetch)", async () => { + const out: string[] = []; + const logs: string[] = []; + await pipePluginResponsesWithStrip( + streamOf(responsesEchoOnlyTurn()), makeRes(out), makeSession(), + (msg) => { logs.push(msg); }, + ); + const text = out.join(""); + assert.equal((text.match(/"type":"response\.completed"/g) ?? []).length, 1, "one turn, one terminal, no re-issue"); + assert.ok(!text.includes("m00155"), "the echoed tag never leaks"); + assert.ok( + logs.some((l) => l.includes("continuation retry not armed")), + `the not-armed pass-through leaves a trace, got: ${JSON.stringify(logs)}`, + ); +}); + test("plugin responses releases the held done-family events on a healthy turn", async () => { const out: string[] = []; let calls = 0;