fix(search): honor configured community search methods by daleselaji-dev · Pull Request #1968 · getzep/graphiti · GitHub
Skip to content

fix(search): honor configured community search methods - #1968

Open
daleselaji-dev wants to merge 1 commit into
getzep:mainfrom
daleselaji-dev:codex/fix-community-search-methods
Open

daleselaji-dev wants to merge 1 commit into
getzep:mainfrom
daleselaji-dev:codex/fix-community-search-methods

Conversation

@daleselaji-dev

Copy link
Copy Markdown

Problem

CommunitySearchConfig.search_methods is ignored by community_search(). Every community search currently runs both full-text (BM25) and cosine-similarity retrieval, even when the caller explicitly selects only one method. This can add unnecessary work and can fail a request through a retrieval method that was intentionally excluded.

Root Cause

community_search() unconditionally passed both retrieval coroutines to semaphore_gather, instead of using the configured CommunitySearchMethod values.

Solution

Build the retrieval task list from CommunitySearchConfig.search_methods before gathering the selected methods.

Changes

  • Run the BM25 community search only when CommunitySearchMethod.bm25 is configured.
  • Run the cosine-similarity community search only when CommunitySearchMethod.cosine_similarity is configured.
  • Add a parameterized regression test proving each single-method configuration skips the other backend.

Testing

  • Baseline: uv run pytest tests/utils/search -q — 33 passed.
  • Focused final: uv run pytest tests/utils/search -q — 35 passed.
  • Format: uv run ruff format --check graphiti_core/search/search.py tests/utils/search/test_community_search.py — passed.
  • Lint: uv run ruff check graphiti_core/search/search.py tests/utils/search/test_community_search.py — passed.
  • Type check: uv run pyright graphiti_core — 0 errors, 0 warnings.
  • Risk-matched unit gate: 605 passed, 12 skipped, 2 unrelated Windows GBK decoding failures in existing intake tests that read repository UTF-8 files without an encoding; the changed search tests passed.
  • git diff --check — passed.
  • Database integration tests were not run because they require Neo4j/FalkorDB services.

Compatibility/Risk

This preserves the default recipe, which explicitly selects both community methods. Configurations selecting one method now execute only that method. No public API, result schema, reranking behavior, or database query is changed beyond avoiding unconfigured retrieval calls.

Notes for Reviewer

The patch is limited to graphiti_core/search/search.py and one unit test. The regression uses mocked retrieval functions and does not require a database or external service. AI assistance was used to prepare this contribution; the final diff and tests were reviewed locally.

Linked Issue

Fixes #1967

@zep-cla-assistant

Copy link
Copy Markdown
Contributor

@gkorland

Copy link
Copy Markdown
Contributor

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Community search ignores configured retrieval methods

2 participants