From 79af2d7b52d4865a82b0a7ad2fb1eb20c3657834 Mon Sep 17 00:00:00 2001 From: sohey Date: Mon, 5 Oct 2026 17:34:52 +0200 Subject: [PATCH] fix(docs-sync): raise output token cap to 16384 for Sonnet 5.5 Each page call returns the full regenerated page. Under Sonnet 5.5 the 4096-token cap truncated seize-and-cancel-units.mdx (8,955 chars), so the page was rejected and dropped from the sync PR (#2069 vs #2054). - DEFAULT_MAX_TOKENS: 4096 -> 16384 (CLAUDE_MAX_TOKENS still overrides) - MAX_REGENERABLE_CHARS: 10000 -> 32000 to match the new budget (~2.2 chars/token measured on Sonnet 5.5) Co-authored-by: Toshi --- scripts/sync-from-base-std/index.mjs | 2 +- scripts/sync-from-base-std/llm/client.mjs | 13 +++++++++++-- scripts/sync-from-base-std/release-utils.mjs | 12 +++++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/scripts/sync-from-base-std/index.mjs b/scripts/sync-from-base-std/index.mjs index 71ee297d1..869c20302 100644 --- a/scripts/sync-from-base-std/index.mjs +++ b/scripts/sync-from-base-std/index.mjs @@ -23,7 +23,7 @@ * LLM_GATEWAY_API_KEY required when any "claude" transformer fires * DRY_RUN=1 optional — don't write files, just log * CLAUDE_MODEL optional — defaults to claude-sonnet-5-5 - * CLAUDE_MAX_TOKENS optional — defaults to 4096 + * CLAUDE_MAX_TOKENS optional — defaults to 16384 * LLM_GATEWAY_BASE_URL optional — overrides the LLM gateway origin * GUIDELINE_ROUTING optional — "propose" (default) surfaces a guideline- * derived placement for unrouted source files in the diff --git a/scripts/sync-from-base-std/llm/client.mjs b/scripts/sync-from-base-std/llm/client.mjs index 48d0c7d6a..50b25569c 100644 --- a/scripts/sync-from-base-std/llm/client.mjs +++ b/scripts/sync-from-base-std/llm/client.mjs @@ -36,8 +36,17 @@ const GATEWAY_BASE_URL = /** Default model — Sonnet 5.5. Override with CLAUDE_MODEL env. */ export const DEFAULT_MODEL = process.env.CLAUDE_MODEL || "claude-sonnet-5-5"; -/** Default max output tokens. Override with CLAUDE_MAX_TOKENS env. */ -export const DEFAULT_MAX_TOKENS = Number(process.env.CLAUDE_MAX_TOKENS || 4096); +/** + * Default max output tokens. Override with CLAUDE_MAX_TOKENS env. + * + * Each page call returns the whole regenerated page, so this cap bounds the + * largest page the sync can edit. 4096 was too small for Sonnet 5.5: its + * tokenizer spends more tokens per char, and an 8,955-char page + * (seize-and-cancel-units.mdx) was truncated and rejected. 16384 fits pages + * of roughly 36k chars. Output is billed per generated token, not per cap, + * and the response is streamed, so a higher cap costs nothing on short pages. + */ +export const DEFAULT_MAX_TOKENS = Number(process.env.CLAUDE_MAX_TOKENS || 16384); /** * Haiku model name. Used by the pre-pass that extracts a structured change diff --git a/scripts/sync-from-base-std/release-utils.mjs b/scripts/sync-from-base-std/release-utils.mjs index ee9d0f8e9..ea03cf3c8 100644 --- a/scripts/sync-from-base-std/release-utils.mjs +++ b/scripts/sync-from-base-std/release-utils.mjs @@ -555,12 +555,14 @@ export function firstHeading(markdown) { // ------------------------------------------------------------ call decision /** - * Largest page (chars) a full regeneration can return inside the 4096-token - * output budget. Measured: 4096 tokens came back as 10.7k–14k chars depending - * on how table-heavy the page is. Above this, the completion is cut off and - * refused, so the call is pointless; skip it before it starts. + * Largest page (chars) a full regeneration can return inside the default + * 16384-token output budget (DEFAULT_MAX_TOKENS in llm/client.mjs). Measured + * on Sonnet 5.5: an 8,955-char page overflowed 4096 tokens, so budget about + * 2.2 chars per token, roughly 36k chars at 16384. Keep a margin below that. + * Above this, the completion is cut off and refused, so the call is + * pointless; skip it before it starts. */ -export const MAX_REGENERABLE_CHARS = 10000; +export const MAX_REGENERABLE_CHARS = 32000; /** Manifest kinds that change an interface's member inventory. */ const INVENTORY_KINDS = new Set([