From 1b8dab204061b236c57d9acffa85764f2514de5b Mon Sep 17 00:00:00 2001 From: paulbettner Date: Mon, 16 Feb 2026 02:51:27 -0500 Subject: [PATCH] fix(create): apply tier updateArgs when model ID selected (#960) --- src/agent/create.ts | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/agent/create.ts b/src/agent/create.ts index 23c5cbc..cfe5ec1 100644 --- a/src/agent/create.ts +++ b/src/agent/create.ts @@ -257,9 +257,14 @@ export async function createAgent( blockProvenance.push({ label: blockId, source: "shared" }); } - // Get the model's context window from its configuration (if known) - // First try models.json, then fall back to API-cached context window for BYOK models - const modelUpdateArgs = getModelUpdateArgs(modelHandle); + // Get the model's context window from its configuration (if known). + // If the caller specified a model *ID* (e.g. gpt-5.3-codex-plus-pro-high), + // use that identifier to preserve tier-specific updateArgs like reasoning_effort. + // Otherwise, fall back to the resolved handle. + const modelIdentifierForDefaults = options.model ?? modelHandle; + const modelUpdateArgs = options.model + ? getModelUpdateArgs(modelIdentifierForDefaults) + : undefined; const contextWindow = (modelUpdateArgs?.context_window as number | undefined) ?? (await getModelContextWindow(modelHandle)); @@ -325,11 +330,17 @@ export async function createAgent( // Note: Preflight check above falls back to 'memory' when 'memory_apply_patch' is unavailable. - // Apply updateArgs if provided (e.g., context_window, reasoning_effort, verbosity, etc.) - // We intentionally pass context_window through so updateAgentLLMConfig can set + // Apply updateArgs if provided (e.g., context_window, reasoning_effort, verbosity, etc.). + // Also apply tier defaults from models.json when the caller explicitly selected a model. + // + // Note: we intentionally pass context_window through so updateAgentLLMConfig can set // context_window_limit using the latest server API, avoiding any fallback. - if (options.updateArgs && Object.keys(options.updateArgs).length > 0) { - await updateAgentLLMConfig(agent.id, modelHandle, options.updateArgs); + const mergedUpdateArgs = { + ...(modelUpdateArgs ?? {}), + ...(options.updateArgs ?? {}), + }; + if (Object.keys(mergedUpdateArgs).length > 0) { + await updateAgentLLMConfig(agent.id, modelHandle, mergedUpdateArgs); } // Always retrieve the agent to ensure we get the full state with populated memory blocks