test(foundation): add examples and unit tests for InMemoryStorage search and history#1221
Open
ashum9 wants to merge 2 commits intomofa-org:mainfrom
Open
test(foundation): add examples and unit tests for InMemoryStorage search and history#1221ashum9 wants to merge 2 commits intomofa-org:mainfrom
ashum9 wants to merge 2 commits intomofa-org:mainfrom
Conversation
…rch and history operations
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the reliability and usability of InMemoryStorage in mofa-foundation by adding async unit tests for search/history/stats behavior and introducing a runnable example demonstrating those APIs.
Changes:
- Added async unit tests for
InMemoryStoragekeyword search (including limit/non-match cases). - Added async unit tests for history tracking and stats reporting (including clear vs clear_history scenarios).
- Added an example program demonstrating storing items, adding conversation history, and running keyword search.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| crates/mofa-foundation/src/agent/components/memory.rs | Adds tokio::test coverage for InMemoryStorage search/history/stats behavior. |
| crates/mofa-foundation/examples/memory_history_search.rs | Adds a runnable demo showcasing history + keyword search usage with InMemoryStorage. |
You can also share your feedback on Copilot code review. Take the survey.
4bc8dcf to
8033d6c
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.
Summary
Enhances the test coverage for the
InMemoryStoragecomponent by adding asynchronous unit tests for its search, history, and statistics capabilities. Additionally, this PR introduces a runnable example to demonstrate these features in practice.Changes
test_in_memory_search): verifies keyword searching across stored documents, correct handling of limits, and non-matching queries including key-level assertions.test_in_memory_history_and_stats): validatesMessagehistory tracking, stats accuracy (total messages, sessions, items), and correctclear()vsclear_history()semantics.examples/memory_history_search.rs): complete demo showcasing how to initializeInMemoryStorage, interact with conversational history, store data, and execute keyword searches.Motivation
Proper search and history tracking are essential features for building complex agent applications. These tests ensure the reliability of these advanced memory operations. The new example provides a practical reference for developers integrating
InMemoryStorageinto their own workflows.cc @amosli @BH3GEI