diff --git a/graphiti_core/graphiti.py b/graphiti_core/graphiti.py index 8c4943e89..45e4bcc05 100644 --- a/graphiti_core/graphiti.py +++ b/graphiti_core/graphiti.py @@ -1114,16 +1114,19 @@ async def add_episode_endpoint(episode_data: EpisodeData): ) # Update communities if requested - communities = [] - community_edges = [] + communities: list[CommunityNode] = [] + community_edges: list[CommunityEdge] = [] if update_communities: - communities, community_edges = await semaphore_gather( + per_node_results = await semaphore_gather( *[ update_community(self.driver, self.llm_client, self.embedder, node) for node in nodes ], max_coroutines=self.max_coroutines, ) + for node_communities, node_community_edges in per_node_results: + communities.extend(node_communities) + community_edges.extend(node_community_edges) end = time()