Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:ANative Lab EvoAgentX MemorySystem

From Leeroopedia
Knowledge Sources
Domains Memory, Agents
Last Updated 2026-10-21 00:00 GMT

Overview

Concrete memory system providing base, short-term, long-term, and LLM-managed memory for agent conversations.

Description

EvoAgentX provides a layered memory system:

  • BaseMemory — Stores `Message` list with indices by action and `wf_goal`. Supports add/get/remove/clear with capacity limit.
  • ShortTermMemory — Extends `BaseMemory` with conversation grouping by `conversation_id`, `get_messages_by_agent`, `get_messages_by_conversation`. Every `Agent` has a `ShortTermMemory` for per-workflow ephemeral context.
  • LongTermMemory — Extends `BaseMemory` with `StorageHandler` and `RAGEngine`. Converts Messages to Chunks with metadata (corpus_id, memory_id, timestamp, action, agent). Supports add/get/search via RAG vector search with deduplication via content hashing. Persists to storage_handler.
  • MemoryManager — Wraps `LongTermMemory` with optional LLM management. `handle_memory` retrieves relevant memories via RAG, optionally prompts LLM to decide operations (add/update/delete), and creates `Message` objects combining user prompts with memory context.

Usage

  • Per-agent context: `ShortTermMemory` is used by every `Agent` during workflow execution.
  • Persistent memory: Use `LongTermMemory` for cross-conversation memory with RAG-based retrieval.
  • Intelligent curation: Use `MemoryManager` when an LLM should decide what to store, update, or forget.

Code Reference

Source Location

Signature

class BaseMemory:
    def add(self, message: Message) -> None
    def get(self, ...) -> List[Message]
    def remove(self, ...) -> None
    def clear(self) -> None

class ShortTermMemory(BaseMemory):
    def get_messages_by_agent(self, agent_name: str) -> List[Message]
    def get_messages_by_conversation(self, conversation_id: str) -> List[Message]

class LongTermMemory(BaseMemory):
    def __init__(self, storage_handler: StorageHandler, rag_engine: RAGEngine, ...)
    def add(self, message: Message) -> None  # Converts to Chunk, indexes
    def search(self, query: str, ...) -> List[Message]  # RAG vector search

class MemoryManager:
    def __init__(self, long_term_memory: LongTermMemory, llm: Optional[BaseLLM] = None, ...)
    async def handle_memory(self, prompt: str, conversation_id: str, ...) -> Message

Import

from evoagentx.memory.memory import BaseMemory, ShortTermMemory
from evoagentx.memory.long_term_memory import LongTermMemory
from evoagentx.memory.memory_manager import MemoryManager

I/O Contract

Inputs

Name Type Required Description
message Message Yes Message to store
query str Yes (search) Search query
conversation_id str No Conversation identifier

Outputs

Name Type Description
get returns List[Message] Retrieved messages
search returns List[Message] RAG-retrieved relevant memories

Usage Examples

Long-Term Memory with RAG

from evoagentx.memory.long_term_memory import LongTermMemory
from evoagentx.storages.base import StorageHandler
from evoagentx.rag.rag import RAGEngine

# Requires storage handler and RAG engine
memory = LongTermMemory(storage_handler=handler, rag_engine=engine)

# Add a message
memory.add(msg)

# Search for relevant past memories
results = memory.search("previous discussion about stocks")

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment