Skip to content

Commit

Permalink
fix(backend): Fix intermittent failure of test_agent_execution (#9210)
Browse files Browse the repository at this point in the history
- Fixed race condition in `create_graph` to preserve node order
- Resolves #9123
  • Loading branch information
Pwuts authored Jan 7, 2025
1 parent 7a9a771 commit 96fae5a
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions autogpt_platform/backend/backend/data/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 96fae5a

Please sign in to comment.