Skip to content

Conversation

@sujalgawas
Copy link
Contributor

Summary

This PR adds a comprehensive test suite for the EpisodicMemory class. The tests verify that initialization, memory insertion, LLM-based importance grading, and top-K retrieval logic behave as expected. This improves reliability and helps catch regressions as the memory module evolves.

Motive

EpisodicMemory is a core component of Mesa-LLM, enabling agents to store, grade, and retrieve memories using LLM-based scoring.
However, there were no dedicated unit tests ensuring these behaviors work consistently.

Implementation

Correct initialization of capacity, system prompt, and deque structure

Proper storage of observation/planning/action memory entries

Importance grading through llm.generate, parsing JSON, and applying prompts

Sorting logic for retrieving top-K entries using
importance - recency_penalty

Usage Examples

The tests ensure:

Entries are stored in a bounded deque
LLM grading returns correct numeric scores
Top-K retrieval returns the highest-ranked memories by importance and recency
If you're modifying the visualisation, add before/after screenshots. -->

@coderabbitai
Copy link

coderabbitai bot commented Oct 29, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Collaborator

@colinfrisch colinfrisch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks a lot for your contribution, I'm going to fully review this asap ! Meanwhile, can you make sure all tests correctly pass (such as style, lint, etc.) ? If you don't have it already, you can install pre-commit (we built a hook for it) to help you with these :)

@colinfrisch colinfrisch self-assigned this Oct 29, 2025
@colinfrisch colinfrisch added the tests Add or improve tests for the repo label Oct 29, 2025
@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.17%. Comparing base (096bbf3) to head (04718ea).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #26      +/-   ##
==========================================
- Coverage   86.30%   86.17%   -0.14%     
==========================================
  Files          17       18       +1     
  Lines        1234     1273      +39     
==========================================
+ Hits         1065     1097      +32     
- Misses        169      176       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sujalgawas
Copy link
Contributor Author

Done.

@colinfrisch colinfrisch self-requested a review October 29, 2025 10:35
Copy link
Collaborator

@colinfrisch colinfrisch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are passing and it looks good to me, thanks for your work !

@colinfrisch colinfrisch merged commit 55be38c into projectmesa:main Oct 31, 2025
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Add or improve tests for the repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants