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 <bash@opencode.itc.local> Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Leonid Skorobogatyy
Bohdan Triapitsyn
parent
2ff5428c69
commit
076e9331ec
@@ -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,
|
||||
|
||||
@@ -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<AgentsStore>()(
|
||||
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<AgentsStore>()(
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user