fix(backend): Fix intermittent failure of test_agent_execution (#9210)

- Fixed race condition in `create_graph` to preserve node order
- Resolves #9123
This commit is contained in:
Reinier van der Leer 2025-01-07 04:42:33 +01:00 committed by GitHub
parent 7a9a771718
commit 96fae5a5c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -629,25 +629,20 @@ async def __create_graph(tx, graph: Graph, user_id: str):
"isTemplate": graph.is_template,
"isActive": graph.is_active,
"userId": user_id,
"AgentNodes": {
"create": [
{
"id": node.id,
"agentBlockId": node.block_id,
"constantInput": json.dumps(node.input_default),
"metadata": json.dumps(node.metadata),
}
for node in graph.nodes
]
},
}
)
await asyncio.gather(
*[
AgentNode.prisma(tx).create(
{
"id": node.id,
"agentBlockId": node.block_id,
"agentGraphId": graph.id,
"agentGraphVersion": graph.version,
"constantInput": json.dumps(node.input_default),
"metadata": json.dumps(node.metadata),
}
)
for node in graph.nodes
]
)
await asyncio.gather(
*[
AgentNodeLink.prisma(tx).create(