From e8fdea066c30df05ebd69f7df6e35bf477f83785 Mon Sep 17 00:00:00 2001 From: awork Date: Sat, 17 Oct 2026 23:35:08 +0800 Subject: [PATCH 1/2] fix(#2924): point the oversize-refusal 422 at a host restart, not a retry (#3589) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The refuse-oversized arm is reachable ONLY via attribution-threw + body-over-window (the host's agent scope died mid-request). In that state retrying the same call keeps failing and compaction is impossible (no fold handle), so the old guidance ('retry the turn; ... needs compaction or a fresh session') was misleading. State why retry is futile and make the remedy a host restart (session state is persisted on disk); fresh session as the fallback. Behavior change (error TEXT only — no logic/wire/code path change): the 422 'message' field of bili_gate_oversize_refusal now says restart-the-client-host instead of retry/compaction. The stable code, HTTP status, x-bili-gate header, and retryable:false are all unchanged. --- src/agent/native-intercept.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/agent/native-intercept.ts b/src/agent/native-intercept.ts index 98be6dbb5e..33573d9310 100644 --- a/src/agent/native-intercept.ts +++ b/src/agent/native-intercept.ts @@ -397,11 +397,14 @@ function bodyByteSizeOf(init: RequestInit | undefined): { bytes: number } | unde /** #2924 direction 1: protocol-shaped local refusal — 422 per the #2709 * precedent (not 401/403 credential-class, not 408/429/5xx transient-class), * so hosts and SDKs treat it as a policy refusal of this ONE request and - * surface it instead of retrying or disabling a credential. */ + * surface it instead of retrying or disabling a credential. Reachable only via + * the threw+oversized arm (the host's agent scope died mid-request): while it + * stays dead, retrying the same call keeps failing, so the remedy is a host + * restart (session state is persisted on disk), not another attempt (#3589). */ function oversizeRefusal(url: string): Response { const message = - "billion-context refused this request locally: host attribution failed mid-request and the request body cannot fit the model's context window — sending it uncompressed would be rejected upstream (#2924). " + - "Retry the turn; if it persists, the session's local history has outgrown the window and needs compaction or a fresh session."; + "billion-context refused this request locally: the host's attribution lookup threw mid-request (its agent scope is disposed/closing), so this body cannot be folded into the model's context window — forwarding it uncompressed would be rejected upstream (#2924). " + + "While that scope stays dead, retrying this same call will keep failing; restart the client host once (its session state is persisted on disk, so nothing is lost) so the oversized history can be folded back under the window. If you cannot restart, start a fresh session instead."; const headers = { "content-type": "application/json", "x-bili-gate": "oversize-refusal" }; if (url.endsWith("/messages")) { return new Response(JSON.stringify({ type: "error", error: { type: "invalid_request_error", message } }), { status: 422, headers }); From a73aae3c025dac3a7506f2e4aeda78159e0f740f Mon Sep 17 00:00:00 2001 From: awork Date: Sun, 18 Oct 2026 00:13:15 +0800 Subject: [PATCH 2/2] =?UTF-8?q?test:=20no-op=20re-run=20of=20windows=20sha?= =?UTF-8?q?rd=20=E2=80=94=20pre-existing=20#3490-class=20teardown=20flake,?= =?UTF-8?q?=20unrelated=20to=20this=20diff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit