From 89ddba68ce46fa3095292fb8a642f494b246f69f Mon Sep 17 00:00:00 2001 From: 1bcMax <195689928+1bcMax@users.noreply.github.com> Date: Mon, 20 Jul 2026 17:24:36 -0500 Subject: [PATCH 1/2] docs(tokens): correct the note claiming gateway max_output is unenforced MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The comment added in 3.35.2 said the gateway's max_output values are 'not enforced: Franklin sends max_tokens 16384 to haiku today and the gateway accepts it.' Accepting the request and honoring it are different things. The gateway clamps with Math.min(request.max_tokens, model.maxOutput) on both handlers and prices the quote off the clamped ceiling — the request is accepted rather than rejected, so the clamp stays invisible until a reply is long enough to hit it. The smoke test that produced that claim returned ten tokens. The conclusion the comment supports is unchanged: the static tables stay authoritative, because the gateway's values are wrong for models we know. Only the reasoning was wrong, and a wrong reason is how a right rule gets reverted later. --- src/gateway-models.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gateway-models.ts b/src/gateway-models.ts index 7ccfaf2..7468e5b 100644 --- a/src/gateway-models.ts +++ b/src/gateway-models.ts @@ -94,9 +94,15 @@ export function clearGatewayModelsCache(): void { * entry for. Callers must treat the static tables as authoritative — the * gateway's own metadata is not reliable (verified 2026-07-20: it reports * max_output 8192 for claude-haiku-4.5, which Anthropic documents as 64000, - * and 64000 for claude-sonnet-4.6, documented as 128000). It is also not - * enforced: Franklin sends max_tokens 16384 to haiku today and the gateway - * accepts it. Treat this as "better than a blind default", nothing more. + * and 64000 for claude-sonnet-4.6, documented as 128000). + * + * Correction to an earlier note here: those values are NOT inert metadata. + * The gateway clamps with them — Math.min(request.max_tokens, model.maxOutput) + * on both the messages and chat/completions handlers — and derives its price + * quote from the clamped ceiling. A request over the advertised cap is + * accepted rather than rejected, so the clamp is invisible until a reply is + * long enough to hit it, which is why a short smoke test looks fine. + * Treat this as "better than a blind default", nothing more. */ export function peekGatewayModel(id: string): GatewayModel | null { if (!cache) return null; From b1f266fcbdb283b72d21c5bb07b3e490a0aabd3f Mon Sep 17 00:00:00 2001 From: 1bcMax <195689928+1bcMax@users.noreply.github.com> Date: Mon, 20 Jul 2026 17:28:28 -0500 Subject: [PATCH 2/2] docs(tokens): make the correction itself precise MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two things the first pass got imprecise, in a comment whose entire job is precision about this mechanism: - It cited 8192 / 64000 in the present tense. Those exact values are being corrected upstream (BlockRunAI/blockrun#266), so the comment was written pre-stale. Reframed as a dated observation, with the durable point stated separately: the catalog can be wrong, and a wrong value here is not cosmetic. - It called the clamp 'invisible' without qualification. The handler does log 'capping to ' — server-side, where no caller sees it (chat/completions/route.ts:1343). Invisible from here, not silent everywhere. Someone who finds that warn should not conclude the comment is wrong again. --- src/gateway-models.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/gateway-models.ts b/src/gateway-models.ts index 7468e5b..f2870e7 100644 --- a/src/gateway-models.ts +++ b/src/gateway-models.ts @@ -92,16 +92,20 @@ export function clearGatewayModelsCache(): void { * Deliberately ignores the TTL: a stale gateway record still beats no record * at all, and the only callers are fallbacks for models we have no static * entry for. Callers must treat the static tables as authoritative — the - * gateway's own metadata is not reliable (verified 2026-07-20: it reports - * max_output 8192 for claude-haiku-4.5, which Anthropic documents as 64000, - * and 64000 for claude-sonnet-4.6, documented as 128000). + * gateway's own metadata has been wrong for models we already know. As of + * 2026-07-20 it reported max_output 8192 for claude-haiku-4.5 (Anthropic + * documents 64000) and 64000 for claude-sonnet-4.6 (documented 128000). + * Those two specific numbers are being corrected upstream, so do not treat + * them as current — the point that outlives them is that the catalog can be + * wrong, and a wrong value here is not cosmetic. * - * Correction to an earlier note here: those values are NOT inert metadata. + * Correction to an earlier note here: these values are NOT inert metadata. * The gateway clamps with them — Math.min(request.max_tokens, model.maxOutput) - * on both the messages and chat/completions handlers — and derives its price - * quote from the clamped ceiling. A request over the advertised cap is - * accepted rather than rejected, so the clamp is invisible until a reply is - * long enough to hit it, which is why a short smoke test looks fine. + * in both the messages and chat/completions handlers — and derives its price + * quote from the clamped ceiling. An over-cap request is accepted rather than + * rejected: the handler logs "capping to " server-side and continues, + * so from here the clamp is invisible until a reply is long enough to hit it. + * That is why a short smoke test against a wrongly-capped model looks healthy. * Treat this as "better than a blind default", nothing more. */ export function peekGatewayModel(id: string): GatewayModel | null {