Skip to main content

AG2 + Memanto

AG2 AG2 (the AutoGen-style multi-agent stack) agents normally forget context when a chat ends. The memanto-ag2 package registers Memanto memory tools on your AssistantAgent and UserProxyAgent so the LLM can store and retrieve durable memory through Moorcheh — the same remember → recall → answer pattern as other Memanto framework adapters.

Drop-in tools

register_memanto_tools() wires memanto_remember, memanto_recall, and memanto_answer in one call.

AG2-native

Plain Python functions with Annotated hints for register_for_llm / register_for_execution.

Shared namespace

One Memanto agent_id per team or app (like a memory bank); GroupChat agents can share it.

Selective tools

Enable or disable remember, recall, or answer with include_* flags.

How It Works

Memanto does not replace AG2 or your LLM. The model chooses when to call memory tools (unlike AgentCore, which recalls automatically before each handler turn). Memory is scoped by agent_id (e.g. my-ag2-team). Use the same id across chats and processes to share memory; use different ids to isolate tenants or teams.

Prerequisites

  • Python 3.10+
  • Memanto and a Moorcheh API key
  • AG2 0.9.x for runtime chat: pip install "ag2>=0.9,<1" (provides from autogen import AssistantAgent)
  • An LLM API key your AG2 config uses (e.g. OPENAI_API_KEY for OpenAI)
Install ag2 (AI agents), not a2g — an unrelated PyPI package. Do not use ag2 1.x with this adapter yet; it uses a different API. Pin ag2>=0.9,<1.

Install

1

Install the adapter

memanto-ag2 installs memanto for you via its package dependencies. Use pip install memanto memanto-ag2 only if you want to pin or upgrade memanto explicitly.
2

Configure Moorcheh

Or run memanto once to write ~/.memanto/.env.

Register tools on your agents

GroupChat with shared memory

Register the same agent_id on every assistant that should read or write shared memory; use one executor (UserProxyAgent) to run tool calls:

Global defaults

Verify persistence

  1. Run a chat that calls memanto_remember (check AG2 logs for EXECUTING FUNCTION memanto_remember and a Memanto memory ID).
  2. Start a new Python process with the same agent_id.
  3. Ask the assistant to memanto_recall or memanto_answer — prior facts should appear even though AG2 chat history is empty.
From the Memanto repo:
Steps 1–5 use the API only. Set OPENAI_API_KEY and install ag2 for optional Step 6 (live AG2 chat). Unit tests (no API key):

AgentCore vs AG2

Shared memory across integrations

All Memanto integration packages use the same Moorcheh-backed agents when they share an agent_id:

Next Steps