Skip to content

fix(memory): return one VikingDB search hit per memory entry - #1216

Open
eric7h wants to merge 1 commit into
volcengine:mainfrom
eric7h:fix/vikingdb-ltm-search-memory-format
Open

eric7h wants to merge 1 commit into
volcengine:mainfrom
eric7h:fix/vikingdb-ltm-search-memory-format

Conversation

@eric7h

@eric7h eric7h commented Nov 7, 2026

Copy link
Copy Markdown

Summary

VikingDBLTMBackend.search_memory took data.result_list and returned a single JSON string whose parts[0].text was str(result_list) — the Python list repr of every hit. LongTermMemory then turned that into one unusable MemoryEntry, discarding per-hit memory_info (summary / profile / event fields) and the top_k shape.

Fix

  • Emit one {"role":"user","parts":[{"text": ...}]} entry per result_list item.
  • Prefer readable fields from memory_info (summary, user_profile, original_messages, question, answer, content, text); otherwise serialize memory_info.

How to reproduce

# Fake collection returning two hits with memory_info.summary:
backend.search_memory(user_id="user-42", query="tea", top_k=5)
# Before (main): 1 string, text starts with "[{'id': 'm1', ...}]"
# After: 2 strings with texts "likes tea" and "lives in Shanghai"

New tests in tests/test_vikingdb_memory_backend.py fail on main and pass with this change. Full file: 22 passed.

Test plan

  • pytest tests/test_vikingdb_memory_backend.py — 22 passed
  • pre-commit (ruff check/format, gitleaks) on touched files

search_memory dumped the entire result_list through str(list) into a
single JSON blob, so callers saw one unusable memory instead of each
hit's memory_info text. Emit one role/parts entry per result.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant