Skip to content

fix(falkordb): route single-group reads onto the group's graph#1572

Open
yimtheppariyapol wants to merge 1 commit into
getzep:mainfrom
yimtheppariyapol:fix/falkordb-single-group-read-routing
Open

fix(falkordb): route single-group reads onto the group's graph#1572
yimtheppariyapol wants to merge 1 commit into
getzep:mainfrom
yimtheppariyapol:fix/falkordb-single-group-read-routing

Conversation

@yimtheppariyapol

Copy link
Copy Markdown

Summary

Single-group reads against FalkorDB return nothing even when the data is physically present in the group's graph. handle_multiple_group_ids only re-routed the driver onto the group graph when len(group_ids) > 1, so a single-group read fell through to the base driver (pinned at default_db) and queried the wrong graph.

Root cause

FalkorDB stores each group_id in its own graph, so a read must clone the driver onto that graph. The decorator gated that routing on len(group_ids) > 1. The write path mutates self.driver onto the group graph, which is why same-process write-then-read tests masked the bug — the reader inherited the mutated driver. A fresh reader process with a single group_id queried default_db and got 0 results.

Reproduced: GRAPH.QUERY <group> showed episodes + facts present; a single-group get_episodes([group]) returned 0; a two-group [group, other] search returned everything (because len > 1 routed).

What changed

  • decorators.py — replace the len > 1 gate with a blank-filtered routable_group_ids (mirrors search()'s != [''] convention). A single real group now routes; a ['']/[None] group no longer routes onto an empty graph name.
  • falkordb_driver.py — memoize clone() per database. __init__ schedules build_indices_and_constraints() on every construction — load-bearing exactly once per group, but pure churn on every subsequent read now that single-group reads clone. Caching keeps the once-per-group index build while removing the per-call constructor cost.

Verification

  • Single-group get_episodes([group]) now returns the group's facts against a live FalkorDB (previously 0).
  • Memoized clone(): repeated clone of the same db returns the same object (no churn); default_group_id maps to default_db; self-clone returns self; a new group is constructed once then cached, and the new group's graph still gets its indices built.

Follow-up (not in this PR)

The write-path self.driver mutation in graphiti.py could be made non-mutating so reads and writes share one routing mechanism, removing the asymmetry that masked this bug.

@zep-cla-assistant

zep-cla-assistant Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

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

@yimtheppariyapol

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: [email protected]

@yimtheppariyapol

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: [email protected]

FalkorDB stores each group_id in its own graph, so a read must clone the
driver onto that graph. `handle_multiple_group_ids` only did this when
`len(group_ids) > 1`, so a single-group read fell through to the base
driver (pinned at default_db) and returned nothing — even though the data
was physically present. The write path mutates `self.driver` onto the
group graph, which masked the bug in same-process write-then-read tests.

Replace the `len > 1` gate with a blank-filtered `routable_group_ids`
(mirrors search()'s `!= ['']` convention), so a single real group routes
and a `['']`/`[None]` group no longer routes onto an empty graph name.

Also memoize `FalkorDriver.clone()` per database. `__init__` schedules
build_indices_and_constraints() on every construction; that is load-bearing
exactly once per group but pure churn on every subsequent read now that
single-group reads clone. Caching keeps the once-per-group index build
while removing the per-call constructor cost.

Follow-up (not in this PR): the write-path `self.driver` mutation in
graphiti.py could be made non-mutating so reads and writes share one
routing mechanism.
@yimtheppariyapol yimtheppariyapol force-pushed the fix/falkordb-single-group-read-routing branch from 1998dcb to a881246 Compare June 11, 2026 09:03
zep-cla-assistant Bot added a commit that referenced this pull request Jun 11, 2026
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.

1 participant