Skip to content

[Bug]: neighborhood re-scoring filters on belongs_to_set (node_name), so expansion nodes are never scored #3914

Description

@Goodnight77

Bug Description

In brute_force_triplet_search (cognee/modules/retrieval/utils/brute_force_triplet_search.py), the neighborhood re-scoring step passes the expansion node ids as node_name. But node_name filters on belongs_to_set, which never contains a node's own id, so the search returns nothing. The expansion nodes then keep the default triplet_distance_penalty and always rank last, which defeats the purpose of the block.

Steps to Reproduce

  1. Run a retrieval that reaches brute_force_triplet_search with neighborhood_depth set, so there are expansion nodes.
  2. The extra re-score search returns nothing, and the expansion nodes stay at the default penalty regardless of similarity.

Expected Behavior

Expansion nodes get real vector scores and take part in triplet ranking.

Actual Behavior

node_name=expansion_ids filters on belongs_to_set, matches nothing, returns [], so expansion nodes keep the default penalty.

Environment

  • OS: any
  • Python version: 3.10 - 3.13
  • Cognee version: dev
  • LLM Provider: any
  • Database: Vector store LanceDB or PGVector (both filter node_name on belongs_to_set)

Logs/Error Messages

None. Silent bug, expansion nodes just always rank last.

Additional Context

Fix in PR #3913. It runs an unfiltered search and keeps only the expansion ids, and removes a dead batch branch in the same block. search() has no id filter today, so an alternative is to add one to the vector adapters. Noted in the PR for maintainer preference.

Pre-submission Checklist

  • I have searched existing issues to ensure this bug hasn't been reported already
  • I have provided a clear and detailed description of the bug
  • I have included steps to reproduce the issue
  • I have included my environment details

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions