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:
parent
7a9a771718
commit
96fae5a5c8
|
@ -629,25 +629,20 @@ async def __create_graph(tx, graph: Graph, user_id: str):
|
||||||
"isTemplate": graph.is_template,
|
"isTemplate": graph.is_template,
|
||||||
"isActive": graph.is_active,
|
"isActive": graph.is_active,
|
||||||
"userId": user_id,
|
"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(
|
await asyncio.gather(
|
||||||
*[
|
*[
|
||||||
AgentNodeLink.prisma(tx).create(
|
AgentNodeLink.prisma(tx).create(
|
||||||
|
|
Loading…
Reference in New Issue