fix(create): apply tier updateArgs when model ID selected (#960)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user