feat: add error handling to VertexAiMemoryBankService.search_memory#5707
Open
vietnamesekid wants to merge 1 commit into
Open
feat: add error handling to VertexAiMemoryBankService.search_memory#5707vietnamesekid wants to merge 1 commit into
vietnamesekid wants to merge 1 commit into
Conversation
043e287 to
6d02714
Compare
6d02714 to
5cc51db
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's the problem?
search_memoryiterates 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:
AttributeError): skips bad entries and logs a warning so the rest still come throughException): if the stream fails partway, we return whatever we already collected instead of raisingAlso added guards for a few edge cases I noticed while looking at this:
memory is Nonefactis empty/Noneupdate_time is None(just setstimestamp=Nonerather than crashing)Test plan
test_search_memory— happy path unchangedtest_search_memory_empty_results— empty results unchangedtest_search_memory_skips_entry_with_none_memorytest_search_memory_skips_entry_with_empty_facttest_search_memory_handles_missing_update_timetest_search_memory_skips_malformed_entrytest_search_memory_returns_partial_results_on_iterator_error