diff --git a/src/agents/provider-transport-fetch.test.ts b/src/agents/provider-transport-fetch.test.ts index 78294feb1f30..8e6e98c18734 100644 --- a/src/agents/provider-transport-fetch.test.ts +++ b/src/agents/provider-transport-fetch.test.ts @@ -1370,7 +1370,7 @@ describe("buildGuardedModelFetch", () => { }); it("errors on oversized SSE body without event boundary in sanitizer", async () => { - const oversized = "x".repeat(65 * 1024); + const oversized = "x".repeat(16 * 1024 * 1024 + 1024); const encoder = new TextEncoder(); fetchWithSsrFGuardMock.mockResolvedValue({ response: new Response( diff --git a/src/agents/provider-transport-fetch.ts b/src/agents/provider-transport-fetch.ts index f8a22bb0752a..75cfcde76428 100644 --- a/src/agents/provider-transport-fetch.ts +++ b/src/agents/provider-transport-fetch.ts @@ -52,9 +52,11 @@ const log = createSubsystemLogger("provider-transport-fetch"); const SSE_SYNTHESIZE_JSON_MAX_BYTES = 16 * 1024 * 1024; /** Max bytes for the internal SSE sanitization buffer between event boundaries. - * A response that cannot find a \n\n boundary within this many characters is - * almost certainly hostile or broken — cap the buffer rather than let it grow. */ -const SSE_SANITIZE_BUFFER_MAX_BYTES = 64 * 1024; + * A single legitimate event (e.g. a large reasoning summary on the chatgpt-responses + * API) can far exceed 64 KiB, so bound this at the same 16 MiB ceiling as the + * JSON-synthesis path: only a genuinely boundary-less (hostile/broken) stream trips + * the guard, not a real large event. */ +const SSE_SANITIZE_BUFFER_MAX_BYTES = 16 * 1024 * 1024; const BLOCKED_EXACT_ORIGIN_TRUST_HOSTNAME_LABELS = new Set(["instance-data"]); const PLAIN_DECIMAL_NUMBER_RE = /^\d+(?:\.\d+)?$/;