Skip to content

fix: route FalkorDB queries to correct graph for single group_id#1326

Open
spencer2211 wants to merge 1 commit intogetzep:mainfrom
spencer2211:fix/falkordb-single-group-id-routing
Open

fix: route FalkorDB queries to correct graph for single group_id#1326
spencer2211 wants to merge 1 commit intogetzep:mainfrom
spencer2211:fix/falkordb-single-group-id-routing

Conversation

@spencer2211
Copy link

Fixes #1325

Summary

The handle_multiple_group_ids decorator only switched the FalkorDB driver to the correct graph database when len(group_ids) > 1. For a single group_id (the most common case), queries fell through to the default execution path, hitting default_db which typically has no data. This caused silent empty results for all FalkorDB deployments using per-query group_ids.

Additionally, all get_by_group_ids classmethods on node and edge types bypassed the decorator entirely, querying the driver directly without routing to the correct FalkorDB graph.

Changes

decorators.py

  • Change len(group_ids) > 1 to len(group_ids) >= 1 so the decorator activates for any non-empty group_ids list

nodes.py (4 methods)

  • Add FalkorDB graph routing to EpisodicNode.get_by_group_ids, EntityNode.get_by_group_ids, CommunityNode.get_by_group_ids, SagaNode.get_by_group_ids

edges.py (5 methods)

  • Add FalkorDB graph routing to EpisodicEdge.get_by_group_ids, EntityEdge.get_by_group_ids, CommunityEdge.get_by_group_ids, HasEpisodeEdge.get_by_group_ids, NextEpisodeEdge.get_by_group_ids

Approach

For each get_by_group_ids method:

  • Single group_id: Clone the driver to target the group's graph database (driver.clone(database=group_ids[0])), then fall through to the existing query logic
  • Multiple group_ids: Query each graph separately via recursive call with a single group_id, merge results, re-sort by UUID descending, and apply limit

This approach avoids code duplication — the single-group case reuses the existing query path, and the multi-group case decomposes cleanly into single-group calls.

Context

FalkorDB uses separate graph databases per group_id, unlike Neo4j which stores all data in a single database and filters by group_id as a node/edge property. The decorator and classmethods need to explicitly switch the driver to the correct graph database before executing queries.

Discovered and verified against a production FalkorDB deployment running graphiti-core with the graphiti MCP server.

The handle_multiple_group_ids decorator only switched the FalkorDB driver
to the correct graph database when len(group_ids) > 1. For a single
group_id (the most common case), queries fell through to the default
execution path, hitting 'default_db' which typically has no data.

Additionally, all get_by_group_ids classmethods on node and edge types
(EpisodicNode, EntityNode, CommunityNode, SagaNode, EpisodicEdge,
EntityEdge, CommunityEdge, HasEpisodeEdge, NextEpisodeEdge) queried the
driver directly without routing through the correct FalkorDB graph
database. Since FalkorDB uses separate graph databases per group_id
(unlike Neo4j which filters by group_id as a node property), these
queries always hit whatever graph the driver was pointed at.

Changes:
- decorators.py: Change len(group_ids) > 1 to >= 1
- nodes.py: Add FalkorDB graph routing to all 4 get_by_group_ids methods
- edges.py: Add FalkorDB graph routing to all 5 get_by_group_ids methods

For single group_id: clone driver to target the group's graph, then fall
through to the existing query logic.
For multiple group_ids: query each graph separately, merge and re-sort
results, apply limit.
@danielchalef
Copy link
Member

danielchalef commented Mar 15, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@spencer2211
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FalkorDB: handle_multiple_group_ids skips graph routing for single group_id

2 participants