Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(deploy): set the proxy heap cap to 768 MiB and the memory limit to 2048Mi
Alfredo Lopez7e3553c001c9
diff --git a/codex-llm-proxy/src/config.ts b/codex-llm-proxy/src/config.tsindex 92359bb07..6bf4301fc 100644--- a/codex-llm-proxy/src/config.ts+++ b/codex-llm-proxy/src/config.ts@@ -91,7 +91,7 @@ export function loadConfig(env: NodeJS.ProcessEnv = process.env): CodexLlmProxyC`CODEX_LLM_PROXY_MAX_VISUAL_BODY_BYTES must be at least ${LIMITS.maxVisualRequestBodyBytes}, the contract maxVisualRequestBodyBytes`)}- // The 1536Mi memory limit was measured with two visual streams at the contract+ // The 2048Mi memory limit was measured with two visual streams at the contract// ceiling only (see IN_FLIGHT_BODY_BUDGET_BODIES). A larger value would admit// bodies that measurement never covered.if (maxVisualBodyBytes > LIMITS.maxVisualRequestBodyBytes) {diff --git a/codex-llm-proxy/src/requestLimits.ts b/codex-llm-proxy/src/requestLimits.tsindex d2e36913a..5bbf93aef 100644--- a/codex-llm-proxy/src/requestLimits.ts+++ b/codex-llm-proxy/src/requestLimits.ts@@ -31,10 +31,12 @@ export const DEFAULT_MAX_BODY_BYTES = CONTRACT_LIMITS.maxRequestBodyBytes + ENVE* RSS with `--max-old-space-size=384` and at 886-1009 MiB with an uncapped* heap, which is why the deployment sets a heap cap. The budget counts bytes,* not structure: bodies at the worst structure the contract admits (262 144- * containers, 262 144 members) are 4.7 MiB each, so it admits about five of- * them parsing at once, each a ~39 MiB tree. That aborted the process at a- * 384 MiB heap cap; the deployment uses 512 MiB and a 1536Mi memory limit,- * the peak of that load (1095-1129 MiB of RSS) plus 25 % (#806 Q1).+ * containers, 262 144 members, 1 048 576 elements) are 2.8 MiB each when+ * compact, so it admits about eight of them parsing at once, or about five at+ * 4.7 MiB, each a ~44 MiB tree. That aborted the process at a 384 MiB heap+ * cap; the deployment uses 768 MiB and a 2048Mi memory limit, the maximum+ * peak of that load (1327-1460 MiB of RSS, macOS, not cgroup memory) plus 25 %+ * (#806 Q1). Charging structure as well as bytes is deferred code work.** Bytes alone do not bound the parse: JSON.parse allocates one heap* object per container, so the contracts cap containers at@@ -88,7 +90,7 @@ export const STREAM_LIMITS = {* The pod cannot hold the ordinary 8-stream gate across a 24 MiB image, so* those requests are a tighter sibling and a V2 request keeps the slot until* the stream ends. Small bodies, including every valid V1, must not enter this- * gate. The 1536Mi limit is sized for these two slots plus the ordinary body+ * gate. The 2048Mi limit is sized for these two slots plus the ordinary body* budget; widening either one needs a new memory measurement first.*/export const VISUAL_STREAM_LIMITS = {diff --git a/codex-llm-proxy/src/server.ts b/codex-llm-proxy/src/server.tsindex dfb134489..3e226698c 100644--- a/codex-llm-proxy/src/server.ts+++ b/codex-llm-proxy/src/server.ts@@ -723,8 +723,8 @@ export function createProxyApps(abort.signal.addEventListener('abort', stopHeartbeat, { once: true })},// #739 D2: the body has been written upstream, so its budget- // reservation ends here rather than with the stream. The parsed- // copy the transport streams from stays; the raw one is dropped.+ // reservation ends here rather than with the stream. Both the raw+ // body and the parsed copy are dropped below (#806 Q1).onUpstreamAccepted: () => {gated.codexBodyRelease?.()gated.codexBodyRelease = undefineddiff --git a/codex-llm-proxy/test/bodyAdmission.test.ts b/codex-llm-proxy/test/bodyAdmission.test.tsindex 4959a139f..cb1bf9675 100644--- a/codex-llm-proxy/test/bodyAdmission.test.ts+++ b/codex-llm-proxy/test/bodyAdmission.test.ts@@ -4,8 +4,10 @@* At an 8 MiB request cap, the stream gate alone would let 24 bodies in (8* running plus 16 queued). Thirteen bodies in flight (eight streams, two* visual, three queued; #739 D5) already peaked at 790 MiB of RSS with the- * heap capped, so 24 would not fit the proxy's 1536Mi limit by that ratio (not- * measured at 24). These tests drive the real runtime app over HTTP and use+ * heap capped. That ratio puts 24 bodies well above 1 GiB (not measured at+ * 24), and it does not hold for structure-dense bodies, whose parsed trees+ * cost far more than their bytes (#806 Q1). These tests drive the real+ * runtime app over HTTP and use* the control-api `redeem` call as the witness: it runs only after the whole* body was read, JSON-parsed, contract-parsed and hash-checked, so the number* of attempts held there is the number of bodies in memory.diff --git a/codex-llm-proxy/test/server.security.test.ts b/codex-llm-proxy/test/server.security.test.tsindex 4a2481097..a85ba74fd 100644--- a/codex-llm-proxy/test/server.security.test.ts+++ b/codex-llm-proxy/test/server.security.test.ts@@ -638,7 +638,7 @@ describe('codex-llm-proxy security surface', () => {expect(loadConfig(required).maxVisualBodyBytes).toBe(24 * 1024 * 1024)})- // The 1536Mi memory limit was measured with two visual streams at the contract+ // The 2048Mi memory limit was measured with two visual streams at the contract// ceiling. A larger visual limit would admit bodies that measurement never// covered, so the proxy refuses to start with one.it('refuses a visual body limit above the contract visual ceiling', () => {diff --git a/deploy/base/control-plane/codex-llm-proxy.yaml b/deploy/base/control-plane/codex-llm-proxy.yamlindex 011ff7998..5c620e937 100644--- a/deploy/base/control-plane/codex-llm-proxy.yaml+++ b/deploy/base/control-plane/codex-llm-proxy.yaml@@ -84,16 +84,19 @@ spec:secretKeyRef:name: codex-llm-proxy-secretskey: CODEX_LLM_PROXY_CONTROL_API_TOKEN- # Caps V8's old space under the 1536Mi limit so the heap is+ # Caps V8's old space under the 2048Mi limit so the heap is# collected before the kernel kills the pod. Measured peak with# eight 8 MiB streams, two 24 MiB visual streams and three queued# 8 MiB bodies (#739 D5): 790 MiB of RSS at a 384 MiB cap, 886-1009- # MiB without one. When the three ordinary bodies carry the worst- # structure the contract admits (#806 Q1), 384 MiB aborts while- # parsing them; 512 MiB is the smallest cap that survives, and that- # load peaked at 1095-1129 MiB of RSS.+ # MiB without one. The byte-based BodyBudget also admits about+ # eight compact bodies of the worst structure the contract admits+ # (#806 Q1), each a ~44 MiB tree once parsed. With 8 held streams,+ # 8 queued bodies and two visual streams, 640 MiB aborted 3 of 3+ # and 768 MiB passed 3 of 3; that load peaked at 1327-1460 MiB of+ # RSS on macOS, which is not cgroup memory. 768 MiB is the smallest+ # cap tested that passes, not a proven minimum.- name: NODE_OPTIONS- value: "--max-old-space-size=512"+ value: "--max-old-space-size=768"ports:- name: runtimecontainerPort: 8080@@ -120,7 +123,7 @@ spec:memory: 768Milimits:cpu: 250m- memory: 1536Mi+ memory: 2048MisecurityContext:allowPrivilegeEscalation: falsereadOnlyRootFilesystem: truediff --git a/deploy/base/control-plane/grok-llm-proxy.yaml b/deploy/base/control-plane/grok-llm-proxy.yamlindex f40acb507..cc89e121a 100644--- a/deploy/base/control-plane/grok-llm-proxy.yaml+++ b/deploy/base/control-plane/grok-llm-proxy.yaml@@ -84,18 +84,21 @@ spec:secretKeyRef:name: grok-llm-proxy-secretskey: GROK_LLM_PROXY_CONTROL_API_TOKEN- # Caps V8's old space under the 1536Mi limit, so heap growth is+ # Caps V8's old space under the 2048Mi limit, so heap growth is# bounded and collected before the kernel kills the pod. The cap# does not lower the peak: with eight 8 MiB streams and three# queued 8 MiB bodies (#739 D5), RSS measured 511 MiB at a 384 MiB# cap and 480-511 MiB without it. One ~36 MB V2 stream in the- # visual slot on top of that load (#784) raised it to 775 MiB. When- # the three ordinary bodies carry the worst structure the contract- # admits (#806 Q1), 384 MiB aborts while parsing them; 512 MiB is- # the smallest cap that survives, and that load peaked at- # 1097-1111 MiB of RSS.+ # visual slot on top of that load (#784) raised it to 775 MiB. The+ # byte-based BodyBudget also admits about eight compact bodies of+ # the worst structure the contract admits (#806 Q1), each a ~44 MiB+ # tree once parsed. With 8 held streams, 8 queued bodies and one+ # V2 stream, 640 MiB passed 3 of 3 for Grok (it aborts the Codex+ # proxy) and 768 MiB passed both; that load peaked at 1212-1482 MiB+ # of RSS on macOS, which is not cgroup memory. 768 MiB is the+ # smallest cap tested that passes both, not a proven minimum.- name: NODE_OPTIONS- value: "--max-old-space-size=512"+ value: "--max-old-space-size=768"ports:- name: runtimecontainerPort: 8080@@ -122,7 +125,7 @@ spec:memory: 768Milimits:cpu: 250m- memory: 1536Mi+ memory: 2048MisecurityContext:allowPrivilegeEscalation: falsereadOnlyRootFilesystem: truediff --git a/docs/architecture/codex-subscription-transport-contract.md b/docs/architecture/codex-subscription-transport-contract.mdindex 41aabbe99..a08881875 100644--- a/docs/architecture/codex-subscription-transport-contract.md+++ b/docs/architecture/codex-subscription-transport-contract.md@@ -242,7 +242,7 @@ window and its source (`catalog` or `default`).`JSON.parse` allocates one heap object per container before any contractcheck runs, so a body within the byte limit can exhaust a capped heap (384 MiB-in the measurements below; the manifest now caps it at 512 MiB, see the end of+in the measurements below; the manifest now caps it at 768 MiB, see the end ofthis section). A 25165824-byte body of `[],` padding aborted `codex-llm-proxy`, andthe contracts accepted 4117647 containers in an 8 MiB request. Both contractstherefore bound the structure as well as the bytes, and every parser checks the@@ -295,16 +295,18 @@ serializations made while forwarding are not included.Worst-structure load (r16, macOS, Node v24.18.0, tsc build, real proxy withundici to a loopback upstream, 29 runs across both proxies). The bodies abovecarry only containers. A body at all three limits (262144 containers, 262144-members, 1048576 elements) parses into about 39 MiB, and the byte budget-admits about five of them at once. Codex with two visual bodies at that shape:-384 MiB heap aborted out of memory with zero upstream hits, 512 MiB passed-(resident after GC 224.8 MiB, peak RSS 1095-1129 MiB). Scales 1.5 and 2 of the-same shape passed at 384 MiB, so the abort is specific to the densest bodies.-The manifest therefore sets `--max-old-space-size=512` and a 1536Mi limit-(`ceil(1129.2 × 1.25)` = 1412 MiB, pinned by `deployManifest.test.ts`), with-the request kept at 768Mi. The resident heap at 512 MiB is still above the-200 MiB target, so a structure-weighted body budget and parsing after the-stream slot is granted remain open as a code change.+members, 1048576 elements) parses into about 44 MiB once collected, and the+byte budget admits about eight compact ones (2.8 MiB each) at once. Codex with+two visual bodies at that shape: 384 MiB heap aborted out of memory with zero+upstream hits, 512 MiB passed. A later run with 8 held streams, 8 queued bodies+and the visual streams aborted at 640 MiB in 3 of 3 runs and passed at 768 MiB+in 3 of 3 (peak RSS 1327-1460 MiB, resident after GC 439.2 MiB; macOS RSS is+not cgroup memory). 768 MiB is the smallest cap tested that passes, not a+proven minimum. The manifest therefore sets `--max-old-space-size=768` and a+2048Mi limit (`ceil(1459.5 × 1.25)` = 1825 MiB, pinned by+`deployManifest.test.ts`), with the request kept at 768Mi. The resident heap+is above the 200 MiB target, so a structure-weighted body budget and parsing+after the stream slot is granted remain open as a code change.The bound does not refuse realistic requests. Tool results and messagecontent are strings, which count only as structural bytes for their quotes; adiff --git a/docs/architecture/grok-subscription-transport-contract.md b/docs/architecture/grok-subscription-transport-contract.mdindex d9d657010..6348269d7 100644--- a/docs/architecture/grok-subscription-transport-contract.md+++ b/docs/architecture/grok-subscription-transport-contract.md@@ -164,15 +164,21 @@ calls through undici, 29 runs): #739's D5 load (eight 8 MiB streams held andthree 8 MiB bodies queued) peaked at 511 MiB, and D5 plus one 36.3 MB V2 streamin the visual gate peaked at 775.4 MiB. A body at the structure limits (262144containers, 262144 members, 1048576 elements) is a worse load: the byte budget-admits about five dense 4.7 MiB bodies at once, and each parse allocates a tree-of about 39 MiB plus transient copies. At a 384 MiB heap cap that load aborted-with out-of-memory before any upstream call; at 512 MiB it passed with a peak-RSS of 1097-1111 MiB. The manifest therefore sets `--max-old-space-size=512`, a-1536Mi limit and a 768Mi request, and+admits about eight compact bodies of that structure (2.8 MiB each) or about+five at 4.7 MiB, and each parse allocates a tree of about 44 MiB once collected,+plus transient copies. At a 384 MiB heap cap that load aborted with+out-of-memory before any upstream call. With 8 held streams, 8 queued bodies+and one V2 stream, 640 MiB passed Grok (peak RSS 1118-1250 MiB) but aborted+the Codex proxy in 3 of 3 runs, and 768 MiB passed both proxies in 3 of 3+(Grok peak RSS 1212-1482 MiB). macOS RSS is not cgroup memory and varied by+about 100 MiB between runs; 768 MiB is the smallest cap tested that passes+both, not a proven minimum. The manifest therefore sets+`--max-old-space-size=768`, a 2048Mi limit and a 768Mi request, and`grok-llm-proxy/test/deployManifest.test.ts` requires the limit to be at least-1.25 × that peak (`ceil(1110.7 × 1.25)` = 1389 MiB). The in-cluster peak is-not measured. The heap cap is a resource change only: the resident heap after-GC at that load was 176.6-208.4 MiB, above the 200 MiB target recorded for+1.25 × the largest peak (`ceil(1481.6 × 1.25)` = 1852 MiB). The in-cluster peak+is not measured (keyper-labs/evenfire-infra#102). The heap cap is a resource+change only: the resident heap after GC at that load was 420.8 MiB, above the+200 MiB target recorded for`BODY_STRUCTURE_LIMITS`, so lowering the resident set needs a code change(a structure-weighted body budget, and parsing after the stream slot isgranted), which is tracked separately.@@ -460,7 +466,7 @@ Proxy robustness (both proxies):`JSON.parse` allocates one heap object per container before any contractcheck runs, so a body within the byte limit can exhaust the proxy's heap cap-(512 MiB, measured; see "Memory" above). A 36700158-byte body of `[],` padding aborted `grok-llm-proxy`, and so+(768 MiB, measured; see "Memory" above). A 36700158-byte body of `[],` padding aborted `grok-llm-proxy`, and sodid three ordinary 8 MiB bodies of 4117647 empty containers each, which thecontract accepted. The fix is the same in both proxies and both contracts, andis described in full, with the measurement, under "Body structure beforediff --git a/grok-llm-proxy/src/config.ts b/grok-llm-proxy/src/config.tsindex 1d4ed00f5..8a1a63d27 100644--- a/grok-llm-proxy/src/config.ts+++ b/grok-llm-proxy/src/config.ts@@ -93,7 +93,7 @@ export function loadConfig(env: NodeJS.ProcessEnv = process.env): GrokLlmProxyCo`GROK_LLM_PROXY_MAX_VISUAL_BODY_BYTES must be at least ${LIMITS.maxVisualRequestBodyBytes}, the contract maxVisualRequestBodyBytes`)}- // The 1536Mi memory limit was measured with one visual stream at the contract+ // The 2048Mi memory limit was measured with one visual stream at the contract// ceiling only (see VISUAL_STREAM_LIMITS). A larger value would admit bodies// that measurement never covered.if (maxVisualBodyBytes > LIMITS.maxVisualRequestBodyBytes) {diff --git a/grok-llm-proxy/src/requestLimits.ts b/grok-llm-proxy/src/requestLimits.tsindex 024e028fc..b579a3e0b 100644--- a/grok-llm-proxy/src/requestLimits.ts+++ b/grok-llm-proxy/src/requestLimits.ts@@ -30,10 +30,11 @@ export const DEFAULT_MAX_BODY_BYTES = CONTRACT_LIMITS.maxRequestBodyBytes + ENVE* why the deployment sets a heap cap. The full load the gates admit adds* one visual stream; `VISUAL_STREAM_LIMITS` records that peak and the memory* limit it sets. The budget counts bytes, not structure: bodies at the worst- * structure the contract admits (262 144 containers, 262 144 members) are- * 4.7 MiB each, so it admits about five of them parsing at once, each a- * ~39 MiB tree. That aborted the process at a 384 MiB heap cap; the- * deployment uses 512 MiB (#806 Q1).+ * structure the contract admits (262 144 containers, 262 144 members,+ * 1 048 576 elements) are 2.8 MiB each when compact, so it admits about eight+ * of them parsing at once, or about five at 4.7 MiB, each a ~44 MiB tree. That+ * aborted the process at a 384 MiB heap cap; the deployment uses 768 MiB+ * (#806 Q1). Charging structure as well as bytes is deferred code work.*/export const IN_FLIGHT_BODY_BUDGET_BODIES = 3@@ -78,11 +79,11 @@ export const STREAM_LIMITS = {* Measured with the full load the gates admit (the D5 load above plus one* ~36 MB V2 stream: a 20 MiB PNG and 8 MiB of text; tsc build, one process,* `--max-old-space-size=384`, upstream request through undici), the process- * peaked at 775 MiB of RSS, against 511 MiB for D5 alone. With the ordinary- * bodies at the worst structure and a 512 MiB heap cap, the same load peaked- * at 1097-1111 MiB. The deployment's 1536Mi memory limit is that peak plus- * 25 %, rounded up; widening this gate or the ordinary body budget needs a- * new memory measurement first.+ * peaked at 775 MiB of RSS, against 511 MiB for D5 alone. With 8 held streams,+ * 8 queued bodies at the worst structure and a 768 MiB heap cap, the same load+ * peaked at 1212-1482 MiB (macOS RSS, not cgroup memory). The deployment's+ * 2048Mi memory limit is the maximum plus 25 %, rounded up; widening this gate+ * or the ordinary body budget needs a new memory measurement first.*/export const VISUAL_STREAM_LIMITS = {maxConcurrentStreams: 1,diff --git a/grok-llm-proxy/src/server.ts b/grok-llm-proxy/src/server.tsindex be029ba47..ff60f4a51 100644--- a/grok-llm-proxy/src/server.ts+++ b/grok-llm-proxy/src/server.ts@@ -735,8 +735,8 @@ export function createProxyApps(abort.signal.addEventListener('abort', stopHeartbeat, { once: true })},// #739 D2: the body has been written upstream, so its budget- // reservation ends here rather than with the stream. The parsed- // copy the transport streams from stays; the raw one is dropped.+ // reservation ends here rather than with the stream. Both the raw+ // body and the parsed copy are dropped below (#806 Q1).onUpstreamAccepted: () => {gated.grokBodyRelease?.()gated.grokBodyRelease = undefineddiff --git a/grok-llm-proxy/test/bodyAdmission.test.ts b/grok-llm-proxy/test/bodyAdmission.test.tsindex d5ecdfd3e..e8f1deca2 100644--- a/grok-llm-proxy/test/bodyAdmission.test.ts+++ b/grok-llm-proxy/test/bodyAdmission.test.ts@@ -3,8 +3,10 @@** At an 8 MiB request cap, the stream gate alone would let 24 bodies in (8* running plus 16 queued). Eleven bodies in flight (eight streams, three- * queued; #739 D5) already peaked at 511 MiB of RSS with the heap capped, so- * 24 would not fit the proxy's 1536Mi limit by that ratio (not measured at 24).+ * queued; #739 D5) already peaked at 511 MiB of RSS with the heap capped. That+ * ratio puts 24 bodies at about 1.1 GiB (not measured at 24), and it does not+ * hold for structure-dense bodies, whose parsed trees cost far more than+ * their bytes (#806 Q1).* These tests drive the real runtime app over HTTP and use the control-api* `redeem` call as the witness: it runs only after the whole* body was read, JSON-parsed, contract-parsed and hash-checked, so the numberdiff --git a/grok-llm-proxy/test/requestLimits.test.ts b/grok-llm-proxy/test/requestLimits.test.tsindex 077f6c8b3..e5a3df4d7 100644--- a/grok-llm-proxy/test/requestLimits.test.ts+++ b/grok-llm-proxy/test/requestLimits.test.ts@@ -398,7 +398,7 @@ describe('StreamGate', () => {// A V2 body above the ordinary cap keeps its image bytes resident for the// whole upstream stream, so it takes a 1-wide sibling of the 8-wide gate.- // Widening it needs a new memory measurement against the 1536Mi limit.+ // Widening it needs a new memory measurement against the 2048Mi limit.it('pins the visual 1/4 sibling, its per-host share, and the ordinary 8/16 gate', () => {expect(VISUAL_STREAM_LIMITS).toEqual({ maxConcurrentStreams: 1, maxQueuedRequests: 4 })expect(VISUAL_PER_HOST_MAX_ADMITTED).toBe(2)diff --git a/grok-llm-proxy/test/server.security.test.ts b/grok-llm-proxy/test/server.security.test.tsindex 2600fb7f9..42461975b 100644--- a/grok-llm-proxy/test/server.security.test.ts+++ b/grok-llm-proxy/test/server.security.test.ts@@ -831,7 +831,7 @@ describe('grok-llm-proxy startup config', () => {).toBe(LIMITS.maxVisualRequestBodyBytes)})- // The 1536Mi memory limit was measured with one visual stream at the contract+ // The 2048Mi memory limit was measured with one visual stream at the contract// ceiling. A larger visual limit would admit bodies that measurement never// covered, so the proxy refuses to start with one.it('refuses a visual body limit above the contract visual ceiling', () => {diff --git a/packages/grok-provider-attempt-contract/bodyStructure.cjs b/packages/grok-provider-attempt-contract/bodyStructure.cjsindex bfd12ecfb..fb64acbfa 100644--- a/packages/grok-provider-attempt-contract/bodyStructure.cjs+++ b/packages/grok-provider-attempt-contract/bodyStructure.cjs@@ -5,8 +5,9 @@** JSON.parse allocates one heap object per container, so a body of `[],`* repeated costs far more heap than its byte count suggests: one 36 MB body- * of that shape aborts a proxy running with --max-old-space-size=384, and- * three 8 MiB ones at once do the same. A byte limit alone cannot prevent+ * of that shape aborts a proxy running with --max-old-space-size=384 (the cap+ * when this was first measured; the deployed cap is now 768), and three 8 MiB+ * ones at once do the same. A byte limit alone cannot prevent* this. This scan runs as the body-parser `verify` hook, after the body is* read and before it is parsed, and refuses a body whose structure could* not belong to a request the contract accepts:diff --git a/packages/grok-provider-attempt-contract/index.cjs b/packages/grok-provider-attempt-contract/index.cjsindex 1fba17e56..04da75325 100644--- a/packages/grok-provider-attempt-contract/index.cjs+++ b/packages/grok-provider-attempt-contract/index.cjs@@ -65,8 +65,8 @@ const LIMITS = Object.freeze({// Objects and arrays in one request, the root included. JSON.parse// allocates a heap object for each, so a request of empty containers fits// maxRequestBodyBytes with about four million of them, and three such- // bodies at once exhaust a proxy capped at --max-old-space-size=384. In- // the Grok proxy, three ordinary bodies and one visual body at twice this+ // bodies at once exhaust a proxy capped at --max-old-space-size=384 (the+ // cap when measured; the deployed cap is now 768). In the Grok proxy, three ordinary bodies and one visual body at twice this// bound kept 197 MiB resident after a full GC. A conversation needs a few// thousand containers; tool results are strings and never count. Must equal// the Codex contract's value.diff --git a/packages/llm-provider-attempt-contract/bodyStructure.cjs b/packages/llm-provider-attempt-contract/bodyStructure.cjsindex bfd12ecfb..fb64acbfa 100644--- a/packages/llm-provider-attempt-contract/bodyStructure.cjs+++ b/packages/llm-provider-attempt-contract/bodyStructure.cjs@@ -5,8 +5,9 @@** JSON.parse allocates one heap object per container, so a body of `[],`* repeated costs far more heap than its byte count suggests: one 36 MB body- * of that shape aborts a proxy running with --max-old-space-size=384, and- * three 8 MiB ones at once do the same. A byte limit alone cannot prevent+ * of that shape aborts a proxy running with --max-old-space-size=384 (the cap+ * when this was first measured; the deployed cap is now 768), and three 8 MiB+ * ones at once do the same. A byte limit alone cannot prevent* this. This scan runs as the body-parser `verify` hook, after the body is* read and before it is parsed, and refuses a body whose structure could* not belong to a request the contract accepts:diff --git a/packages/llm-provider-attempt-contract/index.cjs b/packages/llm-provider-attempt-contract/index.cjsindex f88be0d23..ddfef6cb5 100644--- a/packages/llm-provider-attempt-contract/index.cjs+++ b/packages/llm-provider-attempt-contract/index.cjs@@ -51,8 +51,8 @@ const LIMITS = Object.freeze({// Objects and arrays in one request, the root included. JSON.parse// allocates a heap object for each, so a request of empty containers fits// maxRequestBodyBytes with about four million of them, and three such- // bodies at once exhaust a proxy capped at --max-old-space-size=384. A- // conversation needs a few thousand containers; tool results are strings+ // bodies at once exhaust a proxy capped at --max-old-space-size=384 (the+ // cap when measured; the deployed cap is now 768). A conversation needs a few thousand containers; tool results are strings// and never count. The memory measurement at this bound is in// codex-llm-proxy/src/requestLimits.ts. Must equal the Grok contract's// value.