Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(autogpt_server): Incorrect graph reassignment

SwiftyOS9ae6389c6cd4
diff --git a/rnd/autogpt_server/autogpt_server/data/graph.py b/rnd/autogpt_server/autogpt_server/data/graph.py
index ed090ba90e..7109d6b1bb 100644
--- a/rnd/autogpt_server/autogpt_server/data/graph.py
+++ b/rnd/autogpt_server/autogpt_server/data/graph.py
@@ -123,7 +123,7 @@ class Graph(GraphMeta):
)
return subgraph_map
- def reassign_ids(self):
+ def reassign_ids(self, reassign_graph_id: bool = False):
"""
Reassigns all IDs in the graph to new UUIDs.
This method can be used before storing a new graph to the database.
@@ -131,12 +131,12 @@ class Graph(GraphMeta):
self.validate_graph()
id_map = {
- self.id: str(uuid.uuid4()),
**{node.id: str(uuid.uuid4()) for node in self.nodes},
**{subgraph_id: str(uuid.uuid4()) for subgraph_id in self.subgraphs},
}
- self.id = id_map[self.id]
+ if reassign_graph_id:
+ self.id = str(uuid.uuid4())
for node in self.nodes:
node.id = id_map[node.id]
diff --git a/rnd/autogpt_server/autogpt_server/server/server.py b/rnd/autogpt_server/autogpt_server/server/server.py
index 9fc2983cd4..bc4d5ecaf5 100644
--- a/rnd/autogpt_server/autogpt_server/server/server.py
+++ b/rnd/autogpt_server/autogpt_server/server/server.py
@@ -452,6 +452,7 @@ class AgentServer(AppService):
if create_graph.graph:
graph = create_graph.graph
elif create_graph.template_id:
+ # Create a new graph from a template
graph = await graph_db.get_graph(
create_graph.template_id, create_graph.template_version, template=True
)
@@ -467,7 +468,7 @@ class AgentServer(AppService):
graph.is_template = is_template
graph.is_active = not is_template
- graph.reassign_ids()
+ graph.reassign_ids(reassign_graph_id=True)
return await graph_db.create_graph(graph)