Skip to content

fix: search API silently ignores all memory_types except the first (#78)#138

Open
Exploreunive wants to merge 5 commits intoEverMind-AI:mainfrom
Exploreunive:fix/search-api-support-multiple-memory-types
Open

fix: search API silently ignores all memory_types except the first (#78)#138
Exploreunive wants to merge 5 commits intoEverMind-AI:mainfrom
Exploreunive:fix/search-api-support-multiple-memory-types

Conversation

@Exploreunive
Copy link

@Exploreunive Exploreunive commented Mar 19, 2026

Note on Duplicate PRs

I see PR #89 and #109 also address issue #78. My fix focuses on the minimal change to support multiple memory_types, with:


Problem

The search API accepts a list of memory_types, but the retrieval logic only uses memory_types[0]. All other types are silently ignored — no error, no warning, just missing results.
Example: Sending memory_types=episodic_memory,foresight only searches episodic_memory. The foresight results are never returned.

Fixes #78

Description

Fix the search API to support multiple memory_types instead of silently ignoring all types except the first one.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Related Issues

Fixes #78

Changes Made

  • get_keyword_search_results — loops over all memory_types, searches each ES repo independently, merges results
  • get_vector_search_results — loops over all memory_types, searches each Milvus repo independently, merges results
  • _search_hybrid / _search_rrf — benefit automatically since they call the base methods
  • All retrieve_mem_* methods — logging/metrics now use comma-joined memory_type values (e.g., episodic_memory,foresight)

Design Decisions

  • Embedding computed once — the query vector is generated once and reused across all memory types
  • Graceful degradation — unsupported memory types log a warning and are skipped, rather than failing the entire search
  • Metrics consistencymemory_type in stage metrics now reflects all searched types

Testing

  • Tested locally with manual verification

Test Configuration:

  • OS: Linux
  • Python version: 3.12

Test Results:

GET /api/v1/memories/search?memory_types=episodic_memory,foresight&query=test

…ing the first one

Previously, the search API silently ignored all memory_types except the first one.
Now all specified memory_types are searched and results are merged.

This fixes the issue where passing memory_types=episodic_memory,foresight
would only search episodic_memory and silently ignore foresight.

Fixes EverMind-AI#78
…sponse and retrieve_mem_agentic

The local variable 'memory_type_label' is defined but was incorrectly
referenced as 'memory_type' in 8 places across two methods:

- _to_response: lines 817, 820 (Metadata construction)
- retrieve_mem_agentic: lines 910, 920, 944, 991, 997, 1009
  (record_retrieve_request calls and _rerank positional args)

Using undefined 'memory_type' would cause NameError at runtime
when these code paths are executed.
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.

[bug] Search API only uses memory_types[0], silently ignoring all other types

1 participant