Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(llm-proxy): refuse a visual budget that collapses into the body budget

Alfredo Lopez225ed19f49ac
diff --git a/codex-llm-proxy/test/server.security.test.ts b/codex-llm-proxy/test/server.security.test.ts
index 44221d8e9..c8c6c43f3 100644
--- a/codex-llm-proxy/test/server.security.test.ts
+++ b/codex-llm-proxy/test/server.security.test.ts
@@ -581,6 +581,45 @@ describe('codex-llm-proxy security surface', () => {
).toThrow(/shared envelope byte budget/)
expect(loadConfig(required).maxVisualBodyBytes).toBe(24 * 1024 * 1024)
})
+
+ // Y2 — with an equal budget every visual envelope would also fit the
+ // ordinary parser's cap, so the visual gate's separate admission and memory
+ // accounting would never engage.
+ it('refuses a visual body limit less than or equal to the ordinary body limit', () => {
+ const required = {
+ CODEX_LLM_PROXY_JWT_PUBLIC_KEY: publicKey,
+ CODEX_LLM_PROXY_CONTROL_API_URL:
+ 'http://control-api-rpc-gateway.control-plane.svc.cluster.local:8090/api/v1',
+ CODEX_LLM_PROXY_CONTROL_API_TOKEN: 'dev-codex-llm-proxy-token',
+ }
+ const equal = 24 * 1024 * 1024
+ expect(() =>
+ loadConfig({
+ ...required,
+ CODEX_LLM_PROXY_MAX_BODY_BYTES: String(equal),
+ CODEX_LLM_PROXY_MAX_VISUAL_BODY_BYTES: String(equal),
+ })
+ ).toThrow(
+ 'CODEX_LLM_PROXY_MAX_VISUAL_BODY_BYTES must be greater than CODEX_LLM_PROXY_MAX_BODY_BYTES'
+ )
+ expect(() =>
+ loadConfig({
+ ...required,
+ CODEX_LLM_PROXY_MAX_BODY_BYTES: String(equal + 1),
+ CODEX_LLM_PROXY_MAX_VISUAL_BODY_BYTES: String(equal),
+ })
+ ).toThrow(
+ 'CODEX_LLM_PROXY_MAX_VISUAL_BODY_BYTES must be greater than CODEX_LLM_PROXY_MAX_BODY_BYTES'
+ )
+ // Liveness witness: one byte above the ordinary limit loads.
+ expect(
+ loadConfig({
+ ...required,
+ CODEX_LLM_PROXY_MAX_BODY_BYTES: String(equal),
+ CODEX_LLM_PROXY_MAX_VISUAL_BODY_BYTES: String(equal + 1),
+ }).maxVisualBodyBytes
+ ).toBe(equal + 1)
+ })
})
describe('codex-llm-proxy execution kill switch', () => {
diff --git a/grok-llm-proxy/test/server.security.test.ts b/grok-llm-proxy/test/server.security.test.ts
index e32261b98..355a296f6 100644
--- a/grok-llm-proxy/test/server.security.test.ts
+++ b/grok-llm-proxy/test/server.security.test.ts
@@ -818,6 +818,39 @@ describe('grok-llm-proxy startup config', () => {
).toBe(LIMITS.maxVisualRequestBodyBytes + 1)
})
+ // Y2 — with an equal budget every visual envelope would also fit the
+ // ordinary parser's cap, so the visual gate's separate admission and memory
+ // accounting would never engage.
+ it('refuses a visual body limit less than or equal to the ordinary body limit', () => {
+ const equal = LIMITS.maxVisualRequestBodyBytes
+ expect(() =>
+ loadConfig({
+ ...base,
+ GROK_LLM_PROXY_MAX_BODY_BYTES: String(equal),
+ GROK_LLM_PROXY_MAX_VISUAL_BODY_BYTES: String(equal),
+ })
+ ).toThrow(
+ 'GROK_LLM_PROXY_MAX_VISUAL_BODY_BYTES must be greater than GROK_LLM_PROXY_MAX_BODY_BYTES'
+ )
+ expect(() =>
+ loadConfig({
+ ...base,
+ GROK_LLM_PROXY_MAX_BODY_BYTES: String(equal + 1),
+ GROK_LLM_PROXY_MAX_VISUAL_BODY_BYTES: String(equal),
+ })
+ ).toThrow(
+ 'GROK_LLM_PROXY_MAX_VISUAL_BODY_BYTES must be greater than GROK_LLM_PROXY_MAX_BODY_BYTES'
+ )
+ // Liveness witness: one byte above the ordinary limit loads.
+ expect(
+ loadConfig({
+ ...base,
+ GROK_LLM_PROXY_MAX_BODY_BYTES: String(equal),
+ GROK_LLM_PROXY_MAX_VISUAL_BODY_BYTES: String(equal + 1),
+ }).maxVisualBodyBytes
+ ).toBe(equal + 1)
+ })
+
it('T-R2-6c-grok does not refuse a request at the contract cap with a real ticket as payload_too_large', async () => {
const { runtimeApp } = createProxyApps(config({ maxBodyBytes: loadConfig(base).maxBodyBytes }))
const atCap = { pad: 'x'.repeat(LIMITS.maxRequestBodyBytes - '{"pad":""}'.length) }