Skip to content

Add Memanto long-term memory example for CodeAgent#2516

Open
Neelpatel1604 wants to merge 2 commits into
huggingface:mainfrom
Neelpatel1604:main
Open

Add Memanto long-term memory example for CodeAgent#2516
Neelpatel1604 wants to merge 2 commits into
huggingface:mainfrom
Neelpatel1604:main

Conversation

@Neelpatel1604

Copy link
Copy Markdown

Summary

  • Adds a new examples/memanto/ example showing how to integrate Memanto persistent memory with smolagents using custom Tool classes (same pattern as examples/rag_using_chromadb.py).
  • Includes a thin HTTP client (MemantoClient) for the Memanto REST API, smolagents tools for recall_memory / remember / optional answer_from_memory, and a runnable demo script.
  • Adds mocked unit tests in tests/test_memanto_tools.py (no live Memanto server required in CI).
  • Demo supports OpenAI, LiteLLM/Groq, and Hugging Face Inference via env vars; seeds demo memory only on empty namespaces to avoid duplicates.

What's included

File Description
examples/memanto/memanto_client.py HTTP wrapper: activate session, recall, recall_recent, remember, answer
examples/memanto/memanto_tools.py MemantoRecallTool, MemantoRememberTool, MemantoAnswerTool, create_memanto_tools()
examples/memanto/memanto_memory_agent.py Runnable demo with --seed and --task CLI flags
examples/memanto/README.md Setup and usage documentation
examples/memanto/requirements.txt Example deps (httpx, python-dotenv)
tests/test_memanto_tools.py 9 unit tests with mocked HTTP/client calls

Why custom Tools instead of MCP?

smolagents already supports MCP, but a dedicated Python example is clearer for users who want:

  • Explicit control over which memory operations are exposed
  • No MCP subprocess lifecycle to manage
  • A pattern consistent with existing RAG examples in this repo

Memanto handles cross-session long-term memory; a separate LLM (OpenAI, HF, etc.) is still required for agent reasoning.

Test plan

  • pytest tests/test_memanto_tools.py -v - 9 tests pass (mocked)
  • Manual run with memanto serve + OpenAI (OPENAI_API_KEY):
    memanto agent create smolagents-demo
    memanto serve
    python examples/memanto/memanto_memory_agent.py
  • Verified agent calls recall_memory and returns stored preference
  • Verified duplicate seeding is skipped on subsequent runs (--seed to force)

Prerequisites for reviewers trying the example

pip install -e .
pip install -r examples/memanto/requirements.txt
pip install memanto
memanto agent create smolagents-demo
memanto serve
export OPENAI_API_KEY=...
python examples/memanto/memanto_memory_agent.py

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