From 076e9331ec02c58c4a7d8a6137c2a43c931e3e48 Mon Sep 17 00:00:00 2001 From: bashrusakh <127580858+bashrusakh@users.noreply.github.com> Date: Thu, 25 Jun 2026 01:08:22 +1100 Subject: [PATCH] fix(agents): send null to clear temperature/topP overrides on update (#1718) When clearing temperature or topP on an existing agent, the UI sent undefined which JSON.stringify drops, so the server never received the clear command. Now sends null to properly remove the override in opencode.json. Changed updateAgent to use 'field' in config pattern for temperature and top_p, matching the existing prompt handling. Co-authored-by: Leonid Skorobogatyy Co-authored-by: Bohdan Triapitsyn --- .../components/sections/agents/AgentsPage.tsx | 8 ++++---- packages/ui/src/stores/useAgentsStore.ts | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/ui/src/components/sections/agents/AgentsPage.tsx b/packages/ui/src/components/sections/agents/AgentsPage.tsx index 5686a5d5..a78f7110 100644 --- a/packages/ui/src/components/sections/agents/AgentsPage.tsx +++ b/packages/ui/src/components/sections/agents/AgentsPage.tsx @@ -504,8 +504,8 @@ export const AgentsPage: React.FC = () => { const modeValue = agentDraft.mode || 'subagent'; const modelValue = agentDraft.model || ''; const variantValue = agentDraft.variant || ''; - const temperatureValue = agentDraft.temperature; - const topPValue = agentDraft.top_p; + const temperatureValue = agentDraft.temperature ?? undefined; + const topPValue = agentDraft.top_p ?? undefined; const promptValue = agentDraft.prompt || ''; setDraftName(draftNameValue); @@ -628,8 +628,8 @@ export const AgentsPage: React.FC = () => { mode, model: trimmedModel === '' ? null : trimmedModel, variant: trimmedVariant === '' ? null : trimmedVariant || undefined, - temperature, - top_p: topP, + temperature: temperature ?? null, + top_p: topP ?? null, prompt: trimmedPrompt || (isNewAgent ? undefined : null), permission: permissionConfig, scope: isNewAgent ? draftScope : undefined, diff --git a/packages/ui/src/stores/useAgentsStore.ts b/packages/ui/src/stores/useAgentsStore.ts index ef31b65c..29f3e6ef 100644 --- a/packages/ui/src/stores/useAgentsStore.ts +++ b/packages/ui/src/stores/useAgentsStore.ts @@ -105,8 +105,8 @@ export interface AgentConfig { description?: string; model?: string | null; variant?: string | null; - temperature?: number; - top_p?: number; + temperature?: number | null; + top_p?: number | null; prompt?: string | null; mode?: "primary" | "subagent" | "all"; permission?: PermissionConfig | null; @@ -172,8 +172,8 @@ export interface AgentDraft { description?: string; model?: string | null; variant?: string; - temperature?: number; - top_p?: number; + temperature?: number | null; + top_p?: number | null; prompt?: string; mode?: "primary" | "subagent" | "all"; permission?: PermissionConfig; @@ -334,8 +334,8 @@ export const useAgentsStore = create()( if (config.description) agentConfig.description = config.description; if (config.model) agentConfig.model = config.model; if (config.variant) agentConfig.variant = config.variant; - if (config.temperature !== undefined) agentConfig.temperature = config.temperature; - if (config.top_p !== undefined) agentConfig.top_p = config.top_p; + if (config.temperature !== undefined) agentConfig.temperature = config.temperature ?? null; + if (config.top_p !== undefined) agentConfig.top_p = config.top_p ?? null; if (config.prompt) agentConfig.prompt = config.prompt; if (config.permission) agentConfig.permission = config.permission; if (config.disable !== undefined) agentConfig.disable = config.disable; @@ -399,8 +399,8 @@ export const useAgentsStore = create()( if (config.description !== undefined) agentConfig.description = config.description; if (config.model !== undefined) agentConfig.model = config.model; if ('variant' in config) agentConfig.variant = config.variant ?? null; - if (config.temperature !== undefined) agentConfig.temperature = config.temperature; - if (config.top_p !== undefined) agentConfig.top_p = config.top_p; + if ('temperature' in config) agentConfig.temperature = config.temperature ?? null; + if ('top_p' in config) agentConfig.top_p = config.top_p ?? null; if (config.prompt !== undefined) agentConfig.prompt = config.prompt; if (config.permission !== undefined) agentConfig.permission = config.permission; if (config.disable !== undefined) agentConfig.disable = config.disable;