From 1baa362c80b6a8198ecc8535879c024fd5f4c372 Mon Sep 17 00:00:00 2001 From: ework-agent Date: Mon, 5 Oct 2026 09:56:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20compress.streamSummary=20=E2=80=94?= =?UTF-8?q?=20force=20streaming=20preflight=20summaries=20(#2133)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CONFIGURATION.md | 1 + CONFIGURATION.zh-CN.md | 1 + src/compress-settings.ts | 1 + src/config.ts | 20 +- src/preflight.ts | 7 +- src/server.ts | 6 + tests/preflight-stream-summary-config.test.ts | 267 ++++++++++++++++++ website/config-reference/compress.yaml | 10 + website/docs/index.html | 1 + website/main.js | 2 + 10 files changed, 314 insertions(+), 2 deletions(-) create mode 100644 tests/preflight-stream-summary-config.test.ts diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 32ce8cde1c..2da9e5af6e 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -198,6 +198,7 @@ This index is generated from `website/config-reference/*.yaml` — edit the seed | `compress.emergencyThresholdPercent` | number \| % | "95%" | — | Emergency truncation of oversized tool outputs when history passes this share of the window (must be >= maxContextLimit). | | `compress.outputHeadroomMaxPct` | number \| % | 0.25 | — | Cap on the share of the window reserved for output via max_tokens. | | `compress.nudgeGrowthTokens` | number | 50000 (kernel flat cadence) | — | Growth gate: nudges fire only when a foldable range exceeds baseline growth by this many tokens (flat by design, independent of window size). | +| `compress.streamSummary` | boolean | false (unset) | — | Force preflight summarization to run as a streaming (SSE) call from the first attempt. Needed when the upstream sits behind a gateway that times out long non-streaming completions (e.g. Cloudflare HTTP 524): the error-driven self-learn only sees 400 "stream required" rejections and never arms on gateway timeouts. | | `compress.preserveRecentMessages` | number | kernel ≈5 | — | The most recent messages stay soft-protected from folds. | | `compress.preserveRecentTokens` | number | kernel ≈5000 | — | The most recent tokens stay soft-protected from folds. | | `compress.minCompressRangeChars` | number (deprecated alias: minCompressRange) | kernel ≈5000 | — | Smallest foldable range, in characters; shorter ranges never fold. | diff --git a/CONFIGURATION.zh-CN.md b/CONFIGURATION.zh-CN.md index ca81160819..499b3dcc5e 100644 --- a/CONFIGURATION.zh-CN.md +++ b/CONFIGURATION.zh-CN.md @@ -198,6 +198,7 @@ | `compress.emergencyThresholdPercent` | number \| % | "95%" | — | 历史超过窗口该占比时对超大工具输出做紧急截断(必须 >= maxContextLimit)。 | | `compress.outputHeadroomMaxPct` | number \| % | 0.25 | — | max_tokens 输出预留占窗口的最大比例。 | | `compress.nudgeGrowthTokens` | number | 50000 (kernel flat cadence) | — | 增长门槛:可折叠片段超出基线增长达到该 token 数才发提醒(按设计恒定,与窗口大小无关)。 | +| `compress.streamSummary` | boolean | false (unset) | — | 强制 preflight 摘要从首次尝试起就走流式(SSE)请求。适用于上游位于会掐断长非流式补全的网关之后(如 Cloudflare HTTP 524):错误驱动的自学习只认 400 "stream required",网关超时永远无法触发。 | | `compress.preserveRecentMessages` | number | kernel ≈5 | — | 最近的消息软保护、免于折叠。 | | `compress.preserveRecentTokens` | number | kernel ≈5000 | — | 最近的 token 软保护、免于折叠。 | | `compress.minCompressRangeChars` | number (deprecated alias: minCompressRange) | kernel ≈5000 | — | 可折叠片段的最小字符数;更短的永不折叠。 | diff --git a/src/compress-settings.ts b/src/compress-settings.ts index fdb852f558..c8550a96c7 100644 --- a/src/compress-settings.ts +++ b/src/compress-settings.ts @@ -93,6 +93,7 @@ export function mergeCompress( stripImages: pick("stripImages"), stripImagesKeepRecent: pick("stripImagesKeepRecent"), visibilityMarkers: pick("visibilityMarkers"), + streamSummary: pick("streamSummary"), // `reasoning` is a third nested-object field merged sub-field-wise // exactly like `absorb`/`prompts`: a model-level `threshold` must not // discard a provider-level `drop: false`. diff --git a/src/config.ts b/src/config.ts index a5df96b741..bd528eff33 100644 --- a/src/config.ts +++ b/src/config.ts @@ -259,6 +259,20 @@ export type CompressSettings = { * rebuilt history. `false` suppresses them entirely, for deployments where * models imitate or narrate around the markers (#862). Default `true`. */ visibilityMarkers?: boolean; + /** Force preflight summarization calls to use streaming (SSE) instead of + * the default non-stream call (#2133). The error-driven self-learn flag + * (`session.metadata.preflightStreamSummary`) only fires on a 400 whose + * body says "stream … true" — a gateway that cuts long non-streaming + * completions with a timeout status (Cloudflare's HTTP 524 is the + * canonical case) never triggers it, so every summary round-trip fails + * and preflight spins without folding until an operator hand-edits the + * session file. Set this where such a gateway sits between bili and the + * origin: every preflight summary call then streams from the first + * attempt. Deepest level wins (global → provider → model), so it can be + * scoped to just the affected route; unset = legacy behavior (non-stream + * first, learn on 400). No-op on the Google wire (its summary calls are + * always streamed via :streamGenerateContent). */ + streamSummary?: boolean; /** Override the kernel's compression prompt text (compressPhilosophy / * howToCompressRules / tier2DistillRules / tier3CondenseRules). All four * fields are LOAD-BEARING: the kernel rules were tuned in production and @@ -1475,7 +1489,7 @@ const COMPRESS_SETTING_FIELDS = new Set([ "visibilityMarkers", "rules", "injectTool", "injectNudge", "acknowledgePromptsRisk", "absorb", "ccr", "search", "imageCompression", "prompts", "promptPack", "reasoningGuard", "outputSteering", "priceProfile", - "reconcile", + "reconcile", "streamSummary", ]); // Deduped per unique key set per process (same pattern as @@ -1822,6 +1836,10 @@ export function parseCompressSettings(v: unknown): (CompressSettings & { injectT if (typeof obj.visibilityMarkers !== "boolean") ok = false; else out.visibilityMarkers = obj.visibilityMarkers; } + if ("streamSummary" in obj) { + if (typeof obj.streamSummary !== "boolean") ok = false; + else out.streamSummary = obj.streamSummary; + } if ("rules" in obj) { if (typeof obj.rules !== "boolean") ok = false; else out.rules = obj.rules; diff --git a/src/preflight.ts b/src/preflight.ts index c03fb60e8f..756b6888c8 100644 --- a/src/preflight.ts +++ b/src/preflight.ts @@ -106,6 +106,8 @@ export interface PreflightDeps { unknownBaseline?: boolean; /** #1933 F1: origin of the upstream this request routes to. When it matches the route that learned the session's estimate-calibration factor k̂, every per-round text estimate is scaled by k̂ so gate, per-round exit and final fit judge one payload on the same scale as the trigger that started this invocation; absent or mismatched → raw estimates (legacy behavior). */ upstreamOrigin?: string; + /** #2133: compress.streamSummary resolved true for this request (three-level cascade). The self-learn flag only sees 400 "stream required" rejections, so gateways that time out long non-streaming completions (Cloudflare 524) can never self-heal — this forces SSE from the first attempt instead. */ + forceStreamSummary?: boolean; } export type PreflightFailureKind = "upstream" | "exhausted" | "aborted"; @@ -684,7 +686,10 @@ async function summarizeRange(deps: PreflightDeps, content: string, startRef: st // reject the max_output_tokens parameter. Each capability is learned at // most once (guarded below), so the compatibility retries are bounded: // at most one extra attempt per capability, in either rejection order. - let stream = deps.session.metadata.preflightStreamSummary === true; + // #2133: compress.streamSummary forces SSE from the first attempt — the + // learn path above only sees 400 "stream required" rejections, which a + // gateway timeout (524) never produces. + let stream = deps.session.metadata.preflightStreamSummary === true || deps.forceStreamSummary === true; let includeMaxOutputTokens = !(deps.protocol === "responses" && hasLearnedNoMaxOutputTokens(deps)); for (;;) { try { diff --git a/src/server.ts b/src/server.ts index 8d7a43664d..6f4ee94494 100644 --- a/src/server.ts +++ b/src/server.ts @@ -5871,6 +5871,11 @@ async function preflightCompressIfNeeded( stopHold = beginPreflightHold(res, prepared, log); }, preflightHoldGraceMs()); holdTimer.unref(); + // #2133: compress.streamSummary (same three-level cascade as this request's + // own reqConfig resolution) forces SSE summarization — the error-driven + // learn path can't see gateway timeouts (524/503), so operators behind such + // gateways need a deterministic escape hatch. + const forceStreamSummary = resolveCompress(opts.routes, route?.rewrittenUrl, model, opts.compress).streamSummary === true; let result: PreflightResult; try { result = await preflightCompress( @@ -5892,6 +5897,7 @@ async function preflightCompressIfNeeded( wireOverhead: overheadEstimate, unknownBaseline, upstreamOrigin: currentOrigin, + forceStreamSummary, }, prepared.originalMessages, ); diff --git a/tests/preflight-stream-summary-config.test.ts b/tests/preflight-stream-summary-config.test.ts new file mode 100644 index 0000000000..e024e889c0 --- /dev/null +++ b/tests/preflight-stream-summary-config.test.ts @@ -0,0 +1,267 @@ +import assert from "node:assert/strict"; +import http from "node:http"; +import { once } from "node:events"; +import test from "node:test"; + +process.env.NODE_ENV = "test"; +// One attempt per failed summary call so the 524 repro fails fast instead of +// burning the default replay budget against the fake gateway. +process.env.BILI_REPLAY_RETRY_MAX = "1"; + +import { defaultConfig } from "acp-kernel"; +import { startServer } from "../src/server.ts"; +import { parseCompressSettings, type ProxyOptions } from "../src/config.ts"; +import { mergeCompress } from "../src/compress-settings.ts"; +import { SessionStore, _setStoreForTest } from "../src/persist.ts"; +import { _setForTest as setRegistryForTest } from "../src/registry.ts"; +import { listSessions } from "../src/session.ts"; + +// #2133 regression: an upstream behind a gateway that times out long +// NON-STREAMING completions (Cloudflare answers HTTP 524 "origin is timing +// out") never triggers the #626 self-learn — that path only sees 400 bodies +// matching "stream … true" — so every preflight summary round-trip fails and +// compression spins without folding. compress.streamSummary is the operator +// escape hatch: force SSE from the first attempt, scoped by the three-level +// cascade (global → provider → model). + +const SUMMARY_TEXT = + "CONFIG-FORCED STREAMED SUMMARY: the segment held a deterministic load-growth payload across a dozen turns; every raw marker is derivable from the seed and none carries unique state, so the folded view loses nothing of value for continued work."; + +type Call = { stream: boolean; summary: boolean }; + +function sse(event: string, data: unknown): string { + return `event: ${event}\ndata: ${JSON.stringify(data)}\n\n`; +} + +// Cloudflare-shaped Responses upstream: any non-stream call dies with 524 +// (gateway timeout); stream calls succeed — summaries via delta SSE, the +// forwarded client request via response.completed. +function makeCloudflareUpstream(calls: Call[], forwardBodies: string[]): http.Server { + return http.createServer((req, res) => { + const chunks: Buffer[] = []; + req.on("data", (c: Buffer) => chunks.push(c)); + req.on("end", () => { + const raw = Buffer.concat(chunks).toString("utf8"); + let parsed: { stream?: boolean; instructions?: unknown; input?: unknown } = {}; + try { parsed = JSON.parse(raw); } catch { /* keep {} */ } + const isSummary = typeof parsed.instructions === "string" && Array.isArray(parsed.input) && parsed.input.length === 1; + calls.push({ stream: parsed.stream === true, summary: isSummary }); + if (parsed.stream !== true) { + res.writeHead(524, { "content-type": "application/json" }); + res.end(JSON.stringify({ error: { code: 524, message: "origin is timing out" } })); + return; + } + res.writeHead(200, { "content-type": "text/event-stream", "cache-control": "no-cache" }); + if (isSummary) { + for (const part of [SUMMARY_TEXT.slice(0, 40), SUMMARY_TEXT.slice(40)]) { + res.write(sse("response.output_text.delta", { type: "response.output_text.delta", delta: part })); + } + res.write(sse("response.completed", { type: "response.completed", response: { id: "resp_sum", status: "completed", output: [], usage: { input_tokens: 100, output_tokens: 5 } } })); + } else { + forwardBodies.push(raw); + res.write(sse("response.completed", { + type: "response.completed", + response: { + id: "resp_fwd", + status: "completed", + output: [{ type: "message", role: "assistant", content: [{ type: "output_text", text: "ok" }] }], + usage: { input_tokens: 800, output_tokens: 4 }, + }, + })); + } + res.end(); + }); + }); +} + +function longResponsesInput() { + const input: { type: string; role: string; content: string }[] = []; + for (let i = 0; i < 12; i++) { + input.push({ type: "message", role: i % 2 === 0 ? "user" : "assistant", content: `Message ${i} of the long conversation. ` + `MARKER_${i}_content_`.repeat(250) }); + } + return input; +} + +function startProxy(routes: Record, compress: Record): Promise { + _setStoreForTest(new SessionStore({ enabled: false })); + setRegistryForTest({}); + return startServer({ + port: 0, + host: "127.0.0.1", + upstream: "http://127.0.0.1", + routes, + modelContextLimit: 10_000, + kernelConfig: defaultConfig(10_000), + compress: { injectTool: true, injectNudge: true, ...compress }, + promptCache: { routing: "auto" }, + sessionHeader: "x-acp-session", + log: false, + debug: false, + passthrough: false, + autoUpdate: false, + compat: { roles: {} }, + streamErrorShape: "protocol", + passthroughSource: null, + autoRestartOnUpdate: false, + updateTag: "latest", + advisoryCheck: false, + releaseNotesCheck: false, + mitm: { enabled: false, domains: [] }, + } as ProxyOptions); +} + +async function driveResponsesPreflight(proxyPort: number, upstreamPort: number, session: string): Promise { + return await fetch(`http://127.0.0.1:${proxyPort}/bili/http://127.0.0.1:${upstreamPort}/responses`, { + method: "POST", + headers: { "content-type": "application/json", "x-acp-session": session }, + body: JSON.stringify({ model: "gpt-6-astra", stream: true, input: longResponsesInput() }), + }); +} + +function closeAll(servers: http.Server[]): Promise { + return new Promise((resolve, reject) => { + void Promise.allSettled(servers.map((s) => { s.close(); return once(s, "close"); })).then(() => resolve(), reject); + }); +} + +test("parseCompressSettings validates streamSummary as a strict boolean (#2133)", () => { + assert.equal(parseCompressSettings({ streamSummary: true })?.streamSummary, true); + assert.equal(parseCompressSettings({ streamSummary: false })?.streamSummary, false); + assert.equal(parseCompressSettings({ streamSummary: "yes" }), undefined); + assert.equal(parseCompressSettings({ streamSummary: 1 }), undefined); + assert.equal(parseCompressSettings({ nudgeGrowthTokens: 40000, streamSummary: true })?.nudgeGrowthTokens, 40000); + assert.equal(parseCompressSettings({})?.streamSummary, undefined); +}); + +test("mergeCompress: streamSummary merges deepest-wins like every other field (#2133)", () => { + assert.equal(mergeCompress({ streamSummary: true }, undefined, undefined).streamSummary, true); + assert.equal(mergeCompress(undefined, { streamSummary: true }, undefined).streamSummary, true); + assert.equal(mergeCompress(undefined, undefined, { streamSummary: true }).streamSummary, true); + assert.equal(mergeCompress({ streamSummary: true }, undefined, { streamSummary: false }).streamSummary, false); + assert.equal(mergeCompress({ streamSummary: true }, { streamSummary: false }, undefined).streamSummary, false); + assert.equal(mergeCompress(undefined, undefined, undefined).streamSummary, undefined); +}); + +test("e2e #2133 (global config ON): 524 gateway → SSE forced first-shot, fold applies, nothing learned", async () => { + const calls: Call[] = []; + const forwardBodies: string[] = []; + const upstream = makeCloudflareUpstream(calls, forwardBodies); + upstream.listen(0, "127.0.0.1"); + await once(upstream, "listening"); + const upstreamPort = (upstream.address() as { port: number }).port; + + const proxy = await startProxy( + { [`http://127.0.0.1:${upstreamPort}`]: { models: { "gpt-6-astra": { context: 10_000 } } } }, + { streamSummary: true }, + ); + await once(proxy, "listening"); + const proxyPort = (proxy.address() as { port: number }).port; + + try { + const r = await driveResponsesPreflight(proxyPort, upstreamPort, "s2133-on-1"); + assert.equal(r.status, 200, `forced-stream preflight must succeed behind the 524 gateway, got ${r.status}`); + + // Every summary call went straight to SSE — zero non-stream attempts + // (the legacy behavior is exactly one doomed non-stream round-trip per + // summary before it gives up). + const summaries = calls.filter((c) => c.summary); + assert.ok(summaries.length >= 1, "a summary call must have been made"); + assert.ok( + summaries.every((c) => c.stream), + `every summary call must be stream when compress.streamSummary=true, got ${JSON.stringify(calls)}`, + ); + + // The fold applied: the forwarded payload carries the summary text. + assert.ok(forwardBodies.length >= 1, "the folded payload was forwarded"); + assert.ok(forwardBodies.some((b) => b.includes(SUMMARY_TEXT)), "the applied fold's summary entered the rebuilt payload"); + + // Nothing had to be learned — the session flag stays unset (it is the + // error-driven marker, distinct from the config-forced mode). + const sess = listSessions().find((s) => s.id.includes("s2133-on-1")); + assert.ok(sess, "session recorded"); + assert.equal(sess?.metadata?.preflightStreamSummary, undefined, "no error-driven learning needed under the config-forced mode"); + } finally { + await closeAll([proxy, upstream]); + } +}); + +test("e2e #2133 (config OFF, default): 524 gateway → non-stream first-shot, no self-heal, fail-fast 502", async () => { + const calls: Call[] = []; + const forwardBodies: string[] = []; + const upstream = makeCloudflareUpstream(calls, forwardBodies); + upstream.listen(0, "127.0.0.1"); + await once(upstream, "listening"); + const upstreamPort = (upstream.address() as { port: number }).port; + + const proxy = await startProxy( + { [`http://127.0.0.1:${upstreamPort}`]: { models: { "gpt-6-astra": { context: 10_000 } } } }, + {}, + ); + await once(proxy, "listening"); + const proxyPort = (proxy.address() as { port: number }).port; + + try { + const r = await driveResponsesPreflight(proxyPort, upstreamPort, "s2133-off-1"); + // Pins the UNCHANGED default behavior: without the knob the gateway + // timeout never arms the learn path, so preflight fails fast instead + // of folding (the exact symptom reported in #2133). + assert.equal(r.status, 502, `default behavior must still fail fast behind the 524 gateway, got ${r.status}`); + const body = await r.json() as { error?: { code?: string; retryable?: boolean } }; + assert.equal(body.error?.code, "preflight_compress_failed"); + assert.equal(body.error?.retryable, true); + + const summaries = calls.filter((c) => c.summary); + assert.ok(summaries.length >= 1, "a summary call must have been made"); + assert.ok( + summaries.every((c) => !c.stream), + `without the knob every summary attempt stays non-stream (the 524 never matches the learn regex), got ${JSON.stringify(calls)}`, + ); + assert.equal(forwardBodies.length, 0, "nothing was forwarded — the payload could not be brought under the window"); + } finally { + await closeAll([proxy, upstream]); + } +}); + +test("e2e #2133 (per-provider scope): only the route carrying compress.streamSummary streams", async () => { + const callsA: Call[] = []; + const bodiesA: string[] = []; + const callsB: Call[] = []; + const bodiesB: string[] = []; + const upstreamA = makeCloudflareUpstream(callsA, bodiesA); + const upstreamB = makeCloudflareUpstream(callsB, bodiesB); + // Attach the listeners BEFORE listen(): with two concurrent listens the + // second "listening" event can fire while awaiting the first, and an + // EventEmitter drops unlistened events — the await would hang forever. + const upAReady = once(upstreamA, "listening"); + const upBReady = once(upstreamB, "listening"); + upstreamA.listen(0, "127.0.0.1"); + upstreamB.listen(0, "127.0.0.1"); + await Promise.all([upAReady, upBReady]); + const portA = (upstreamA.address() as { port: number }).port; + const portB = (upstreamB.address() as { port: number }).port; + + const proxy = await startProxy( + { + [`http://127.0.0.1:${portA}`]: { models: { "gpt-6-astra": { context: 10_000 } }, compress: { streamSummary: true } }, + [`http://127.0.0.1:${portB}`]: { models: { "gpt-6-astra": { context: 10_000 } } }, + }, + {}, + ); + await once(proxy, "listening"); + const proxyPort = (proxy.address() as { port: number }).port; + + try { + const rA = await driveResponsesPreflight(proxyPort, portA, "s2133-scope-a"); + assert.equal(rA.status, 200, "route A carries the provider-level knob and must fold cleanly"); + const sumsA = callsA.filter((c) => c.summary); + assert.ok(sumsA.length >= 1 && sumsA.every((c) => c.stream), `route A summaries must all be stream, got ${JSON.stringify(callsA)}`); + + const rB = await driveResponsesPreflight(proxyPort, portB, "s2133-scope-b"); + assert.equal(rB.status, 502, "route B has no knob and keeps the legacy non-stream-first behavior"); + const sumsB = callsB.filter((c) => c.summary); + assert.ok(sumsB.length >= 1 && sumsB.every((c) => !c.stream), `route B summaries must stay non-stream, got ${JSON.stringify(callsB)}`); + assert.equal(bodiesB.length, 0, "route B forwarded nothing (its preflight failed)"); + } finally { + await closeAll([proxy, upstreamA, upstreamB]); + } +}); diff --git a/website/config-reference/compress.yaml b/website/config-reference/compress.yaml index 650e2becf1..fffad92188 100644 --- a/website/config-reference/compress.yaml +++ b/website/config-reference/compress.yaml @@ -52,6 +52,16 @@ entries: desc_zh: "增长门槛:可折叠片段超出基线增长达到该 token 数才发提醒(按设计恒定,与窗口大小无关)。" site_en: "Growth gate (default 50000): nudges fire only when a foldable range exceeds baseline growth by this many tokens." site_zh: "增长门槛(默认 50000):可折叠片段超出基线增长达到该 token 数才发提醒。" + - key: compress.streamSummary + type: boolean + default: "false (unset)" + group: compress + id: cw.ssm + render: compress-row + desc_en: "Force preflight summarization to run as a streaming (SSE) call from the first attempt. Needed when the upstream sits behind a gateway that times out long non-streaming completions (e.g. Cloudflare HTTP 524): the error-driven self-learn only sees 400 \"stream required\" rejections and never arms on gateway timeouts." + desc_zh: "强制 preflight 摘要从首次尝试起就走流式(SSE)请求。适用于上游位于会掐断长非流式补全的网关之后(如 Cloudflare HTTP 524):错误驱动的自学习只认 400 \"stream required\",网关超时永远无法触发。" + site_en: "Force streaming (SSE) summarization from the first attempt — an escape hatch for upstreams behind gateways that time out long non-streaming calls (e.g. Cloudflare 524), which the error-driven self-learn cannot detect." + site_zh: "强制摘要从首次起走流式(SSE)——用于上游在会掐断长非流式调用的网关之后(如 Cloudflare 524),错误自学习无法感知该场景。" - key: compress.preserveRecentMessages type: number default: "kernel ≈5" diff --git a/website/docs/index.html b/website/docs/index.html index b3036d501f..85a85ce8d3 100644 --- a/website/docs/index.html +++ b/website/docs/index.html @@ -177,6 +177,7 @@

compress — every knob

emergencyThresholdPercentnumber | %Default "95%": emergency truncation of oversized tool outputs when history passes this share of the window (must be ≥ maxContextLimit). outputHeadroomMaxPctnumber | %Cap (0–1, default 0.25) on the share of the window reserved for output via max_tokens. nudgeGrowthTokensnumberGrowth gate (default 50000): nudges fire only when a foldable range exceeds baseline growth by this many tokens. + streamSummarybooleanForce streaming (SSE) summarization from the first attempt — an escape hatch for upstreams behind gateways that time out long non-streaming calls (e.g. Cloudflare 524), which the error-driven self-learn cannot detect. preserveRecentMessagesnumberKernel default ≈5: the most recent messages stay soft-protected from folds. preserveRecentTokensnumberKernel default ≈5000: the most recent tokens stay soft-protected from folds. minCompressRangeCharsnumber (deprecated alias: minCompressRange)Smallest foldable range, in characters (kernel default ≈5000) — shorter ranges never fold. diff --git a/website/main.js b/website/main.js index a5942824ae..51c36a2862 100644 --- a/website/main.js +++ b/website/main.js @@ -65,6 +65,7 @@ "cw.etc": "Default \"95%\": emergency truncation of oversized tool outputs when history passes this share of the window (must be ≥ maxContextLimit).", "cw.ohmp": "Cap (0–1, default 0.25) on the share of the window reserved for output via max_tokens.", "cw.ngt": "Growth gate (default 50000): nudges fire only when a foldable range exceeds baseline growth by this many tokens.", + "cw.ssm": "Force streaming (SSE) summarization from the first attempt — an escape hatch for upstreams behind gateways that time out long non-streaming calls (e.g. Cloudflare 524), which the error-driven self-learn cannot detect.", "cw.prm": "Kernel default ≈5: the most recent messages stay soft-protected from folds.", "cw.prt": "Kernel default ≈5000: the most recent tokens stay soft-protected from folds.", "cw.mrc": "Smallest foldable range, in characters (kernel default ≈5000) — shorter ranges never fold.", @@ -275,6 +276,7 @@ "cw.etc": "默认 \"95%\":历史超过窗口该占比时,对超大工具输出做紧急截断(必须 ≥ maxContextLimit)。", "cw.ohmp": "max_tokens 输出预留占窗口的最大比例(0–1,默认 0.25)。", "cw.ngt": "增长门槛(默认 50000):可折叠片段超出基线增长达到该 token 数才发提醒。", + "cw.ssm": "强制摘要从首次起走流式(SSE)——用于上游在会掐断长非流式调用的网关之后(如 Cloudflare 524),错误自学习无法感知该场景。", "cw.prm": "内核默认约 5:最近消息软保护、免于折叠。", "cw.prt": "内核默认约 5000:最近的 token 软保护、免于折叠。", "cw.mrc": "可折叠片段的最小字符数(内核默认约 5000),更短的永不折叠。", From 949bda21aadb3fb2916b83e9da7f7c29541374af Mon Sep 17 00:00:00 2001 From: ework-agent Date: Mon, 5 Oct 2026 09:56:10 +0800 Subject: [PATCH 2/2] fix: align misindented stripImages line in mergeCompress (cosmetic, found while working #2133) --- src/compress-settings.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compress-settings.ts b/src/compress-settings.ts index c8550a96c7..b4f74b08d9 100644 --- a/src/compress-settings.ts +++ b/src/compress-settings.ts @@ -90,7 +90,7 @@ export function mergeCompress( imageCompression: imageCompressionLevels.length > 0 ? Object.assign({}, ...imageCompressionLevels) : undefined, rules: pick("rules"), -stripImages: pick("stripImages"), + stripImages: pick("stripImages"), stripImagesKeepRecent: pick("stripImagesKeepRecent"), visibilityMarkers: pick("visibilityMarkers"), streamSummary: pick("streamSummary"),