Skip to content

fix(falkordb): episode_mentions_reranker inverted ordering and min_score bypass#1687

Open
Naseem77 wants to merge 4 commits into
getzep:mainfrom
FalkorDB:fix/falkordb-episode-mentions-reranker
Open

fix(falkordb): episode_mentions_reranker inverted ordering and min_score bypass#1687
Naseem77 wants to merge 4 commits into
getzep:mainfrom
FalkorDB:fix/falkordb-episode-mentions-reranker

Conversation

@Naseem77

Copy link
Copy Markdown
Contributor

What it fixes

Two related bugs in FalkorSearchOperations.episode_mentions_reranker (graphiti_core/driver/falkordb/operations/search_ops.py):

1. Ranking is inverted

Scores are episode-mention counts (higher = more relevant), but the sort was ascending, so the least-mentioned nodes ranked first. A node mentioned by 3 episodes ranked below a node mentioned by 1.

2. Unmentioned nodes bypass min_score

Nodes with no MENTIONS edges were given float('inf') as a score, which passes any min_score threshold (and, combined with the ascending sort, also pushed them to the end rather than filtering them). They now score 0, so any positive min_score filters them out.

Related: #1342 reported the inverted ordering for the legacy search_utils.py path (fix pending in #1640/#1512), but this ops-layer copy has the same bugs and is not covered by those PRs.

Before / after

With Popular mentioned by 3 episodes, Rare by 1, Unmentioned by 0:

await driver.search_ops.episode_mentions_reranker(driver, uuids)
# before: ['Rare', 'Popular', 'Unmentioned']
# after:  ['Popular', 'Rare', 'Unmentioned']

await driver.search_ops.episode_mentions_reranker(driver, uuids, min_score=2)
# before: ['Popular', 'Unmentioned']   (inf >= 2)
# after:  ['Popular']

Validation

  • New FalkorDB integration test covering both ordering and min_score; verified it fails on the unfixed code and passes with the fix
  • Full tests/driver suite passes against a live FalkorDB

@zep-cla-assistant

zep-cla-assistant Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

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

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