mirror of https://github.com/kortix-ai/suna.git
fix: model preservation during update
This commit is contained in:
parent
89a4996dfd
commit
ae81e8e403
|
@ -120,6 +120,7 @@ async def update_agent(
|
|||
"version_number": 1,
|
||||
"version_name": "v1",
|
||||
"system_prompt": existing_data.get('system_prompt', ''),
|
||||
"model": existing_data.get('model'),
|
||||
"configured_mcps": existing_data.get('configured_mcps', []),
|
||||
"custom_mcps": existing_data.get('custom_mcps', []),
|
||||
"agentpress_tools": existing_data.get('agentpress_tools', {}),
|
||||
|
@ -150,6 +151,7 @@ async def update_agent(
|
|||
else:
|
||||
current_version_data = {
|
||||
'system_prompt': existing_data.get('system_prompt', ''),
|
||||
'model': existing_data.get('model'),
|
||||
'configured_mcps': existing_data.get('configured_mcps', []),
|
||||
'custom_mcps': existing_data.get('custom_mcps', []),
|
||||
'agentpress_tools': existing_data.get('agentpress_tools', {})
|
||||
|
@ -158,6 +160,7 @@ async def update_agent(
|
|||
logger.warning(f"Failed to create initial version for agent {agent_id}: {e}")
|
||||
current_version_data = {
|
||||
'system_prompt': existing_data.get('system_prompt', ''),
|
||||
'model': existing_data.get('model'),
|
||||
'configured_mcps': existing_data.get('configured_mcps', []),
|
||||
'custom_mcps': existing_data.get('custom_mcps', []),
|
||||
'agentpress_tools': existing_data.get('agentpress_tools', {})
|
||||
|
@ -181,6 +184,10 @@ async def update_agent(
|
|||
needs_new_version = True
|
||||
version_changes['system_prompt'] = agent_data.system_prompt
|
||||
|
||||
if values_different(agent_data.model, current_version_data.get('model')):
|
||||
needs_new_version = True
|
||||
version_changes['model'] = agent_data.model
|
||||
|
||||
if values_different(agent_data.configured_mcps, current_version_data.get('configured_mcps', [])):
|
||||
needs_new_version = True
|
||||
version_changes['configured_mcps'] = agent_data.configured_mcps
|
||||
|
@ -220,6 +227,7 @@ async def update_agent(
|
|||
print(f"[DEBUG] update_agent: Prepared update_data with icon fields - icon_name={update_data.get('icon_name')}, icon_color={update_data.get('icon_color')}, icon_background={update_data.get('icon_background')}")
|
||||
|
||||
current_system_prompt = agent_data.system_prompt if agent_data.system_prompt is not None else current_version_data.get('system_prompt', '')
|
||||
current_model = agent_data.model if agent_data.model is not None else current_version_data.get('model')
|
||||
|
||||
if agent_data.configured_mcps is not None:
|
||||
if agent_data.replace_mcps:
|
||||
|
@ -257,6 +265,7 @@ async def update_agent(
|
|||
agent_id=agent_id,
|
||||
user_id=user_id,
|
||||
system_prompt=current_system_prompt,
|
||||
model=current_model,
|
||||
configured_mcps=current_configured_mcps,
|
||||
custom_mcps=current_custom_mcps,
|
||||
agentpress_tools=current_agentpress_tools,
|
||||
|
|
|
@ -25,6 +25,7 @@ class AgentUpdateRequest(BaseModel):
|
|||
name: Optional[str] = None
|
||||
description: Optional[str] = None
|
||||
system_prompt: Optional[str] = None
|
||||
model: Optional[str] = None
|
||||
configured_mcps: Optional[List[Dict[str, Any]]] = None
|
||||
custom_mcps: Optional[List[Dict[str, Any]]] = None
|
||||
agentpress_tools: Optional[Dict[str, Any]] = None
|
||||
|
|
|
@ -140,7 +140,7 @@ export function AgentConfigurationDialog({
|
|||
const newFormData = {
|
||||
name: configSource.name || '',
|
||||
system_prompt: configSource.system_prompt || '',
|
||||
model: configSource.model,
|
||||
model: configSource.model || undefined,
|
||||
agentpress_tools: ensureCoreToolsEnabled(configSource.agentpress_tools || DEFAULT_AGENTPRESS_TOOLS),
|
||||
configured_mcps: configSource.configured_mcps || [],
|
||||
custom_mcps: configSource.custom_mcps || [],
|
||||
|
@ -177,7 +177,7 @@ export function AgentConfigurationDialog({
|
|||
agentpress_tools: formData.agentpress_tools,
|
||||
};
|
||||
|
||||
if (formData.model !== undefined) updateData.model = formData.model;
|
||||
if (formData.model !== undefined && formData.model !== null) updateData.model = formData.model;
|
||||
if (formData.icon_name !== undefined) updateData.icon_name = formData.icon_name;
|
||||
if (formData.icon_color !== undefined) updateData.icon_color = formData.icon_color;
|
||||
if (formData.icon_background !== undefined) updateData.icon_background = formData.icon_background;
|
||||
|
@ -254,7 +254,7 @@ export function AgentConfigurationDialog({
|
|||
};
|
||||
|
||||
const handleModelChange = (model: string) => {
|
||||
setFormData(prev => ({ ...prev, model }));
|
||||
setFormData(prev => ({ ...prev, model: model || undefined }));
|
||||
};
|
||||
|
||||
const handleToolsChange = (tools: Record<string, boolean | { enabled: boolean; description: string }>) => {
|
||||
|
|
|
@ -267,7 +267,6 @@ export const StreamlinedInstallDialog: React.FC<StreamlinedInstallDialogProps> =
|
|||
</div>
|
||||
</div>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="mt-6">
|
||||
{isLoading ? (
|
||||
<div className="flex items-center justify-center py-12">
|
||||
|
|
|
@ -6,6 +6,7 @@ export type Agent = {
|
|||
agent_id: string;
|
||||
name: string;
|
||||
system_prompt: string;
|
||||
model?: string | null;
|
||||
configured_mcps: Array<{
|
||||
name: string;
|
||||
config: Record<string, any>;
|
||||
|
@ -97,8 +98,6 @@ export type AgentCreateRequest = {
|
|||
}>;
|
||||
agentpress_tools?: Record<string, any>;
|
||||
is_default?: boolean;
|
||||
// New
|
||||
// Icon system fields
|
||||
icon_name?: string | null;
|
||||
icon_color?: string | null;
|
||||
icon_background?: string | null;
|
||||
|
@ -106,7 +105,7 @@ export type AgentCreateRequest = {
|
|||
|
||||
export type AgentVersionCreateRequest = {
|
||||
system_prompt: string;
|
||||
model?: string; // Add model field
|
||||
model?: string;
|
||||
configured_mcps?: Array<{
|
||||
name: string;
|
||||
config: Record<string, any>;
|
||||
|
@ -143,6 +142,7 @@ export type AgentUpdateRequest = {
|
|||
name?: string;
|
||||
description?: string;
|
||||
system_prompt?: string;
|
||||
model?: string | null;
|
||||
configured_mcps?: Array<{
|
||||
name: string;
|
||||
config: Record<string, any>;
|
||||
|
@ -155,12 +155,9 @@ export type AgentUpdateRequest = {
|
|||
}>;
|
||||
agentpress_tools?: Record<string, any>;
|
||||
is_default?: boolean;
|
||||
// New
|
||||
// Icon system fields
|
||||
icon_name?: string | null;
|
||||
icon_color?: string | null;
|
||||
icon_background?: string | null;
|
||||
// MCP replacement flag
|
||||
replace_mcps?: boolean;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue