fix agent creation

This commit is contained in:
Saumya 2025-07-30 23:37:36 +05:30
parent c005d6f166
commit b36715d2b6
2 changed files with 24 additions and 30 deletions

View File

@ -1623,42 +1623,38 @@ async def create_agent(
change_description="Initial version"
)
agent['current_version_id'] = version['version_id']
agent['current_version_id'] = version.version_id
agent['version_count'] = 1
# Create proper AgentVersionResponse from version dict
current_version = AgentVersionResponse(
version_id=version['version_id'],
agent_id=version['agent_id'],
version_number=version['version_number'],
version_name=version['version_name'],
system_prompt=version['system_prompt'],
configured_mcps=version.get('configured_mcps', []),
custom_mcps=version.get('custom_mcps', []),
agentpress_tools=version.get('agentpress_tools', {}),
is_active=version.get('is_active', True),
created_at=version['created_at'],
updated_at=version.get('updated_at', version['created_at']),
created_by=version.get('created_by')
version_id=version.version_id,
agent_id=version.agent_id,
version_number=version.version_number,
version_name=version.version_name,
system_prompt=version.system_prompt,
configured_mcps=version.configured_mcps,
custom_mcps=version.custom_mcps,
agentpress_tools=version.agentpress_tools,
is_active=version.is_active,
created_at=version.created_at.isoformat(),
updated_at=version.updated_at.isoformat(),
created_by=version.created_by
)
except Exception as 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()
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}")
# Use version data for the response
return AgentResponse(
agent_id=agent['agent_id'],
account_id=agent['account_id'],
name=agent['name'],
description=agent.get('description'),
system_prompt=version['system_prompt'],
configured_mcps=version.get('configured_mcps', []),
custom_mcps=version.get('custom_mcps', []),
agentpress_tools=version.get('agentpress_tools', {}),
system_prompt=version.system_prompt,
configured_mcps=version.configured_mcps,
custom_mcps=version.custom_mcps,
agentpress_tools=version.agentpress_tools,
is_default=agent.get('is_default', False),
is_public=agent.get('is_public', False),
tags=agent.get('tags', []),

View File

@ -199,14 +199,12 @@ export function AgentVersionSwitcher({
})}
</div>
{versions.length === 1 && (
<div className="p-2">
<Alert>
<AlertCircle className="h-4 w-4" />
<AlertDescription>
This is the first version. Make changes to create a new version.
</AlertDescription>
</Alert>
</div>
<Alert>
<AlertCircle className="h-4 w-4" />
<AlertDescription>
This is the first version. Make changes to create a new version.
</AlertDescription>
</Alert>
)}
</DropdownMenuContent>
</DropdownMenu>