mirror of https://github.com/kortix-ai/suna.git
Merge pull request #1140 from escapade-mckv/fix-agent-creation
fix agent creation
This commit is contained in:
commit
91e1468f39
|
@ -1623,42 +1623,38 @@ async def create_agent(
|
||||||
change_description="Initial version"
|
change_description="Initial version"
|
||||||
)
|
)
|
||||||
|
|
||||||
agent['current_version_id'] = version['version_id']
|
agent['current_version_id'] = version.version_id
|
||||||
agent['version_count'] = 1
|
agent['version_count'] = 1
|
||||||
|
|
||||||
# Create proper AgentVersionResponse from version dict
|
|
||||||
current_version = AgentVersionResponse(
|
current_version = AgentVersionResponse(
|
||||||
version_id=version['version_id'],
|
version_id=version.version_id,
|
||||||
agent_id=version['agent_id'],
|
agent_id=version.agent_id,
|
||||||
version_number=version['version_number'],
|
version_number=version.version_number,
|
||||||
version_name=version['version_name'],
|
version_name=version.version_name,
|
||||||
system_prompt=version['system_prompt'],
|
system_prompt=version.system_prompt,
|
||||||
configured_mcps=version.get('configured_mcps', []),
|
configured_mcps=version.configured_mcps,
|
||||||
custom_mcps=version.get('custom_mcps', []),
|
custom_mcps=version.custom_mcps,
|
||||||
agentpress_tools=version.get('agentpress_tools', {}),
|
agentpress_tools=version.agentpress_tools,
|
||||||
is_active=version.get('is_active', True),
|
is_active=version.is_active,
|
||||||
created_at=version['created_at'],
|
created_at=version.created_at.isoformat(),
|
||||||
updated_at=version.get('updated_at', version['created_at']),
|
updated_at=version.updated_at.isoformat(),
|
||||||
created_by=version.get('created_by')
|
created_by=version.created_by
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error creating initial version: {str(e)}")
|
logger.error(f"Error creating initial version: {str(e)}")
|
||||||
# Clean up the agent if version creation fails
|
|
||||||
await client.table('agents').delete().eq('agent_id', agent['agent_id']).execute()
|
await client.table('agents').delete().eq('agent_id', agent['agent_id']).execute()
|
||||||
raise HTTPException(status_code=500, detail="Failed to create initial version")
|
raise HTTPException(status_code=500, detail="Failed to create initial version")
|
||||||
|
|
||||||
logger.info(f"Created agent {agent['agent_id']} with v1 for user: {user_id}")
|
logger.info(f"Created agent {agent['agent_id']} with v1 for user: {user_id}")
|
||||||
|
|
||||||
# Use version data for the response
|
|
||||||
return AgentResponse(
|
return AgentResponse(
|
||||||
agent_id=agent['agent_id'],
|
agent_id=agent['agent_id'],
|
||||||
account_id=agent['account_id'],
|
account_id=agent['account_id'],
|
||||||
name=agent['name'],
|
name=agent['name'],
|
||||||
description=agent.get('description'),
|
description=agent.get('description'),
|
||||||
system_prompt=version['system_prompt'],
|
system_prompt=version.system_prompt,
|
||||||
configured_mcps=version.get('configured_mcps', []),
|
configured_mcps=version.configured_mcps,
|
||||||
custom_mcps=version.get('custom_mcps', []),
|
custom_mcps=version.custom_mcps,
|
||||||
agentpress_tools=version.get('agentpress_tools', {}),
|
agentpress_tools=version.agentpress_tools,
|
||||||
is_default=agent.get('is_default', False),
|
is_default=agent.get('is_default', False),
|
||||||
is_public=agent.get('is_public', False),
|
is_public=agent.get('is_public', False),
|
||||||
tags=agent.get('tags', []),
|
tags=agent.get('tags', []),
|
||||||
|
|
|
@ -199,14 +199,12 @@ export function AgentVersionSwitcher({
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
{versions.length === 1 && (
|
{versions.length === 1 && (
|
||||||
<div className="p-2">
|
<Alert>
|
||||||
<Alert>
|
<AlertCircle className="h-4 w-4" />
|
||||||
<AlertCircle className="h-4 w-4" />
|
<AlertDescription>
|
||||||
<AlertDescription>
|
This is the first version. Make changes to create a new version.
|
||||||
This is the first version. Make changes to create a new version.
|
</AlertDescription>
|
||||||
</AlertDescription>
|
</Alert>
|
||||||
</Alert>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
|
|
Loading…
Reference in New Issue