@@ -204,6 +204,7 @@ async def create_agent(db: Session, agent: AgentCreate) -> Agent:
204204
205205 elif agent .type == "crew_ai" :
206206 if not isinstance (agent .config , dict ):
207+ agent .config = {}
207208 raise HTTPException (
208209 status_code = status .HTTP_400_BAD_REQUEST ,
209210 detail = "Invalid configuration: must be an object with tasks" ,
@@ -221,7 +222,6 @@ async def create_agent(db: Session, agent: AgentCreate) -> Agent:
221222 detail = "Invalid configuration: tasks cannot be empty" ,
222223 )
223224
224- # Validar se todos os agent_id nas tasks existem
225225 for task in agent .config ["tasks" ]:
226226 if "agent_id" not in task :
227227 raise HTTPException (
@@ -237,15 +237,13 @@ async def create_agent(db: Session, agent: AgentCreate) -> Agent:
237237 detail = f"Agent not found for task: { agent_id } " ,
238238 )
239239
240- # Validar sub_agents se existir
241240 if "sub_agents" in agent .config and agent .config ["sub_agents" ]:
242241 if not validate_sub_agents (db , agent .config ["sub_agents" ]):
243242 raise HTTPException (
244243 status_code = status .HTTP_400_BAD_REQUEST ,
245244 detail = "One or more sub-agents do not exist" ,
246245 )
247246
248- # Gerar API key se não existir
249247 if "api_key" not in agent .config or not agent .config ["api_key" ]:
250248 agent .config ["api_key" ] = generate_api_key ()
251249
@@ -684,7 +682,6 @@ async def update_agent(
684682 if "config" not in agent_data :
685683 agent_data ["config" ] = agent_config
686684
687- # Validar configuração de crew_ai, se aplicável
688685 if ("type" in agent_data and agent_data ["type" ] == "crew_ai" ) or (
689686 agent .type == "crew_ai" and "config" in agent_data
690687 ):
@@ -701,7 +698,6 @@ async def update_agent(
701698 detail = "Invalid configuration: tasks cannot be empty" ,
702699 )
703700
704- # Validar se todos os agent_id nas tasks existem
705701 for task in config ["tasks" ]:
706702 if "agent_id" not in task :
707703 raise HTTPException (
0 commit comments