Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix: raise the non-image request cap to 8 MiB in both contracts (#731)
Alfredo Lopez0d39eec241cb
diff --git a/codex-llm-proxy/test/runtimePath.hermetic.e2e.test.ts b/codex-llm-proxy/test/runtimePath.hermetic.e2e.test.tsindex 97cf9add4..a4cfa68bb 100644--- a/codex-llm-proxy/test/runtimePath.hermetic.e2e.test.ts+++ b/codex-llm-proxy/test/runtimePath.hermetic.e2e.test.ts@@ -41,6 +41,7 @@ import {type RedeemAttemptSuccess,} from '../src/controlApiClient.js'import { CODEX_CATALOG_ORIGIN, CODEX_COMPLETIONS_ORIGIN } from '../src/originPolicy.js'+import { DEFAULT_MAX_BODY_BYTES } from '../src/requestLimits.js'import { type ProxyServers, createProxyApps } from '../src/server.js'import { eventaskUpdateTool, optionalMcpTools } from './fixtures/optionalMcpTools.js'@@ -79,7 +80,7 @@ function config(): CodexLlmProxyConfig {runtimePort: 0,adminPort: 0,probePort: 0,- maxBodyBytes: 1_048_576,+ maxBodyBytes: DEFAULT_MAX_BODY_BYTES,maxStreamDurationMs: 30_000,maxDeadlineMs: 30_000,jwtIssuer: 'control-api',diff --git a/codex-llm-proxy/test/sseBackpressure.test.ts b/codex-llm-proxy/test/sseBackpressure.test.tsindex 7902b39b5..23ee1721c 100644--- a/codex-llm-proxy/test/sseBackpressure.test.ts+++ b/codex-llm-proxy/test/sseBackpressure.test.ts@@ -15,6 +15,7 @@ import type {RedeemAttemptSuccess,} from '../src/controlApiClient.js'import { CODEX_CATALOG_ORIGIN, CODEX_COMPLETIONS_ORIGIN } from '../src/originPolicy.js'+import { DEFAULT_MAX_BODY_BYTES } from '../src/requestLimits.js'import { createProxyApps, writeSseChunk } from '../src/server.js'function fakeResponse(writeResult: boolean) {@@ -89,7 +90,7 @@ function config(): CodexLlmProxyConfig {runtimePort: 0,adminPort: 0,probePort: 0,- maxBodyBytes: 1_048_576,+ maxBodyBytes: DEFAULT_MAX_BODY_BYTES,maxStreamDurationMs: 60_000,maxDeadlineMs: 60_000,jwtIssuer: 'control-api',diff --git a/grok-llm-proxy/src/grokTransport.ts b/grok-llm-proxy/src/grokTransport.tsindex 3e6983ca4..2664809e3 100644--- a/grok-llm-proxy/src/grokTransport.ts+++ b/grok-llm-proxy/src/grokTransport.ts@@ -58,12 +58,12 @@ export const GROK_UPSTREAM_TEMPERATURE_PROBE_CONFIRMED: boolean = false* so a long run of `response.function_call_arguments.delta` events grows the* proxy's heap and the response body without any ceiling.*- * Interim value, matched to `LIMITS.maxRequestBodyBytes` so a response cannot- * be larger than a request the Host is allowed to send back. Issue #731 owns- * the end-to-end size budget and will replace this constant with the value the- * contract derives; keep the two in sync until then.+ * Read from `LIMITS.maxRequestBodyBytes` so a response cannot be larger than a+ * request the Host is allowed to send back (#731). The retained text is held+ * in memory until the response ends, so raising the contract cap raises this+ * per-stream heap ceiling with it.*/-export const MAX_TOOL_CALL_ARGUMENT_CHARS = 1_048_576+export const MAX_TOOL_CALL_ARGUMENT_CHARS: number = LIMITS.maxRequestBodyBytesexport class GrokTransportError extends Error {constructor(diff --git a/grok-llm-proxy/test/runtimePath.hermetic.e2e.test.ts b/grok-llm-proxy/test/runtimePath.hermetic.e2e.test.tsindex 9de6db4af..92162a9ba 100644--- a/grok-llm-proxy/test/runtimePath.hermetic.e2e.test.ts+++ b/grok-llm-proxy/test/runtimePath.hermetic.e2e.test.ts@@ -38,6 +38,7 @@ import {} from '../src/controlApiClient.js'import { GROK_UPSTREAM_USER_AGENT } from '../src/grokUpstreamHeaders.js'import { GROK_CATALOG_ORIGIN, GROK_COMPLETIONS_ORIGIN } from '../src/originPolicy.js'+import { DEFAULT_MAX_BODY_BYTES } from '../src/requestLimits.js'import { type ProxyServers, createProxyApps } from '../src/server.js'const ACCESS_TOKEN = 'test-access-hermetic-grok'@@ -75,7 +76,7 @@ function config(overrides: Partial<GrokLlmProxyConfig> = {}): GrokLlmProxyConfigruntimePort: 0,adminPort: 0,probePort: 0,- maxBodyBytes: 1_048_576,+ maxBodyBytes: DEFAULT_MAX_BODY_BYTES,maxStreamDurationMs: 30_000,maxDeadlineMs: 30_000,jwtIssuer: 'control-api',diff --git a/grok-llm-proxy/test/sseBackpressure.test.ts b/grok-llm-proxy/test/sseBackpressure.test.tsindex d90235c10..1e3fe96fa 100644--- a/grok-llm-proxy/test/sseBackpressure.test.ts+++ b/grok-llm-proxy/test/sseBackpressure.test.ts@@ -15,6 +15,7 @@ import type {RedeemAttemptSuccess,} from '../src/controlApiClient.js'import { GROK_CATALOG_ORIGIN, GROK_COMPLETIONS_ORIGIN } from '../src/originPolicy.js'+import { DEFAULT_MAX_BODY_BYTES } from '../src/requestLimits.js'import { createProxyApps, writeSseChunk } from '../src/server.js'function fakeResponse(writeResult: boolean) {@@ -89,7 +90,7 @@ function config(): GrokLlmProxyConfig {runtimePort: 0,adminPort: 0,probePort: 0,- maxBodyBytes: 1_048_576,+ maxBodyBytes: DEFAULT_MAX_BODY_BYTES,maxStreamDurationMs: 60_000,maxDeadlineMs: 60_000,jwtIssuer: 'control-api',diff --git a/packages/grok-provider-attempt-contract/index.cjs b/packages/grok-provider-attempt-contract/index.cjsindex 8ec088aef..fbaa8535a 100644--- a/packages/grok-provider-attempt-contract/index.cjs+++ b/packages/grok-provider-attempt-contract/index.cjs@@ -17,7 +17,12 @@ const COMPLETIONS_ORIGIN = 'https://cli-chat-proxy.grok.com/v1/responses'const CATALOG_ORIGIN = 'https://cli-chat-proxy.grok.com/v1/models'const LIMITS = Object.freeze({- maxRequestBodyBytes: 1048576,+ // 8 MiB of serialized request (#731). A 1M-token window is about 4 MB of+ // text, and escaped JSON tool results cost 1.3-1.5x that, so this covers the+ // largest listed model window; past it the model refuses on tokens first.+ // It is a non-image cap, and the element bound in checkStructure follows+ // this value 1:1.+ maxRequestBodyBytes: 8388608,maxMessages: 1024,// Bounds the `toolCalls` array of a single assistant message, independently// of how many definitions the request advertises. The 1:4 spread againstdiff --git a/packages/grok-provider-attempt-contract/index.d.ts b/packages/grok-provider-attempt-contract/index.d.tsindex f50b4cee9..d19f413d8 100644--- a/packages/grok-provider-attempt-contract/index.d.ts+++ b/packages/grok-provider-attempt-contract/index.d.ts@@ -15,7 +15,7 @@ export declare const COMPLETIONS_ORIGIN: 'https://cli-chat-proxy.grok.com/v1/resexport declare const CATALOG_ORIGIN: 'https://cli-chat-proxy.grok.com/v1/models'export declare const LIMITS: {- readonly maxRequestBodyBytes: 1048576+ readonly maxRequestBodyBytes: 8388608readonly maxMessages: 1024readonly maxToolCalls: 256readonly maxOutputTokens: 16384diff --git a/packages/llm-provider-attempt-contract/index.cjs b/packages/llm-provider-attempt-contract/index.cjsindex 9e8a5e23d..b6c88fa3c 100644--- a/packages/llm-provider-attempt-contract/index.cjs+++ b/packages/llm-provider-attempt-contract/index.cjs@@ -13,7 +13,12 @@ const PROVIDER_ID = 'codex-subscription'const TICKET_TYP = 'codex-execution-ticket'const LIMITS = Object.freeze({- maxRequestBodyBytes: 1048576,+ // 8 MiB of serialized request (#731). A 1M-token window is about 4 MB of+ // text, and escaped JSON tool results cost 1.3-1.5x that, so this covers the+ // largest listed model window; past it the model refuses on tokens first.+ // It is a non-image cap: image bytes get their own ceiling (#660), and the+ // element bound in checkStructure follows this value 1:1.+ maxRequestBodyBytes: 8388608,maxMessages: 1024,// Bound calls in each assistant message independently of advertised definitions.// A turn of N calls adds N+1 messages, so N stays <= maxMessages/4. At thisdiff --git a/packages/llm-provider-attempt-contract/index.d.ts b/packages/llm-provider-attempt-contract/index.d.tsindex 4e9958325..9c76691c5 100644--- a/packages/llm-provider-attempt-contract/index.d.ts+++ b/packages/llm-provider-attempt-contract/index.d.ts@@ -14,7 +14,7 @@ export declare const PROVIDER_ID: 'codex-subscription'export declare const TICKET_TYP: 'codex-execution-ticket'export declare const LIMITS: {- readonly maxRequestBodyBytes: 1048576+ readonly maxRequestBodyBytes: 8388608readonly maxMessages: 1024readonly maxToolCalls: 256readonly maxOutputTokens: 16384diff --git a/tests/e2e/fixtures/codex-subscription/sanitized-upstream-contract.json b/tests/e2e/fixtures/codex-subscription/sanitized-upstream-contract.jsonindex 2a0339ba4..bfabd1092 100644--- a/tests/e2e/fixtures/codex-subscription/sanitized-upstream-contract.json+++ b/tests/e2e/fixtures/codex-subscription/sanitized-upstream-contract.json@@ -40,7 +40,7 @@},"oauthScopes": ["openid", "profile", "email", "offline_access"],"limits": {- "maxRequestBodyBytes": 1048576,+ "maxRequestBodyBytes": 8388608,"maxMessages": 1024,"maxToolCalls": 256,"maxOutputTokens": 16384,diff --git a/tests/e2e/fixtures/grok-subscription/sanitized-upstream-contract.json b/tests/e2e/fixtures/grok-subscription/sanitized-upstream-contract.jsonindex b6b27622c..9b4f4f717 100644--- a/tests/e2e/fixtures/grok-subscription/sanitized-upstream-contract.json+++ b/tests/e2e/fixtures/grok-subscription/sanitized-upstream-contract.json@@ -54,7 +54,7 @@"cliImpersonation": false},"limits": {- "maxRequestBodyBytes": 1048576,+ "maxRequestBodyBytes": 8388608,"maxMessages": 1024,"maxToolCalls": 256,"maxOutputTokens": 16384,diff --git a/tests/e2e/fixtures/package-lock.json b/tests/e2e/fixtures/package-lock.jsonindex 0710b38c1..85e91fde0 100644--- a/tests/e2e/fixtures/package-lock.json+++ b/tests/e2e/fixtures/package-lock.json@@ -1,12 +1,12 @@{"name": "@clerum/e2e-test-fixtures",- "version": "1.0.88",+ "version": "1.0.89","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "@clerum/e2e-test-fixtures",- "version": "1.0.88",+ "version": "1.0.89","dependencies": {"@kubernetes/client-node": "^1.0.0"},diff --git a/tests/e2e/fixtures/package.json b/tests/e2e/fixtures/package.jsonindex 1e7319e6d..19d45b543 100644--- a/tests/e2e/fixtures/package.json+++ b/tests/e2e/fixtures/package.json@@ -1,6 +1,6 @@{"name": "@clerum/e2e-test-fixtures",- "version": "1.0.88",+ "version": "1.0.89","description": "E2E test fixtures and utilities for Clerum testing","type": "module","main": "index.ts",