Skip to content

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

TypeScript

fix(llm-proxy): refuse BodyBudget sizes it cannot enforce

Alfredo Lopez5542ebc697cd
diff --git a/codex-llm-proxy/src/requestLimits.ts b/codex-llm-proxy/src/requestLimits.ts
index 9a5ec8c3d..4c209f4c6 100644
--- a/codex-llm-proxy/src/requestLimits.ts
+++ b/codex-llm-proxy/src/requestLimits.ts
@@ -246,7 +246,16 @@ export class BodyBudget {
constructor(
private readonly capacityBytes: number,
private readonly maxQueued: number = STREAM_LIMITS.maxQueuedRequests
- ) {}
+ ) {
+ // The same standard as StreamGate: a NaN capacity would queue every body
+ // until the queue is full, and an infinite one would admit every body.
+ if (!Number.isSafeInteger(capacityBytes) || capacityBytes < 1) {
+ throw new RangeError('capacityBytes must be a positive integer')
+ }
+ if (!Number.isInteger(maxQueued) || maxQueued < 0) {
+ throw new RangeError('maxQueued must be a non-negative integer')
+ }
+ }
get inFlightBytes(): number {
return this.inFlight
diff --git a/grok-llm-proxy/src/requestLimits.ts b/grok-llm-proxy/src/requestLimits.ts
index 7496b9085..da39e4209 100644
--- a/grok-llm-proxy/src/requestLimits.ts
+++ b/grok-llm-proxy/src/requestLimits.ts
@@ -226,7 +226,16 @@ export class BodyBudget {
constructor(
private readonly capacityBytes: number,
private readonly maxQueued: number = STREAM_LIMITS.maxQueuedRequests
- ) {}
+ ) {
+ // The same standard as StreamGate: a NaN capacity would queue every body
+ // until the queue is full, and an infinite one would admit every body.
+ if (!Number.isSafeInteger(capacityBytes) || capacityBytes < 1) {
+ throw new RangeError('capacityBytes must be a positive integer')
+ }
+ if (!Number.isInteger(maxQueued) || maxQueued < 0) {
+ throw new RangeError('maxQueued must be a non-negative integer')
+ }
+ }
get inFlightBytes(): number {
return this.inFlight