Skip to content

feat: add error handling to VertexAiMemoryBankService.search_memory#5707

Open
vietnamesekid wants to merge 1 commit into
google:mainfrom
vietnamesekid:feat/vertex-memory-bank-error-handling
Open

feat: add error handling to VertexAiMemoryBankService.search_memory#5707
vietnamesekid wants to merge 1 commit into
google:mainfrom
vietnamesekid:feat/vertex-memory-bank-error-handling

Conversation

@vietnamesekid
Copy link
Copy Markdown

What's the problem?

search_memory iterates over memory entries from the Vertex AI API but had no error handling. If one entry was malformed or the iterator threw mid-stream, the whole call would blow up and drop everything collected so far.

What changed?

Added two layers of defense inside the iterator loop:

  • Per-entry (AttributeError): skips bad entries and logs a warning so the rest still come through
  • Iterator-level (Exception): if the stream fails partway, we return whatever we already collected instead of raising

Also added guards for a few edge cases I noticed while looking at this:

  • memory is None
  • fact is empty/None
  • update_time is None (just sets timestamp=None rather than crashing)

Test plan

  • test_search_memory — happy path unchanged
  • test_search_memory_empty_results — empty results unchanged
  • test_search_memory_skips_entry_with_none_memory
  • test_search_memory_skips_entry_with_empty_fact
  • test_search_memory_handles_missing_update_time
  • test_search_memory_skips_malformed_entry
  • test_search_memory_returns_partial_results_on_iterator_error

@vietnamesekid vietnamesekid force-pushed the feat/vertex-memory-bank-error-handling branch from 043e287 to 6d02714 Compare May 15, 2026 03:10
@vietnamesekid vietnamesekid force-pushed the feat/vertex-memory-bank-error-handling branch from 6d02714 to 5cc51db Compare May 15, 2026 03:13
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