← Back to Skills Marketplace
laojun509

Agent Memory Enterprise

by laojun · GitHub ↗ · v0.1.0 · MIT-0
cross-platform ⚠ suspicious
115
Downloads
0
Stars
1
Active Installs
1
Versions
Install in OpenClaw
/install agent-memory-enterprise
Description
Enterprise-grade 5-layer agent memory system with routing, scoring, and multi-backend storage. Use when building production AI agents that need persistent me...
README (SKILL.md)

Agent Memory Pro

Enterprise-grade 5-layer long-term memory system for AI agents with intelligent routing, importance scoring, and multi-backend storage support.

Overview

This is a production-ready implementation of the 5-layer memory architecture from Wang Fuqiang's article "How to Design an Agent Long-term Memory System".

5 Memory Layers

┌─────────────────────────────────────────────────────────────┐
│  Context Memory    - Conversation window management         │
│  (seconds-minutes) - Token budget + sliding window          │
├─────────────────────────────────────────────────────────────┤
│  Task Memory       - Multi-step task tracking               │
│  (minutes-hours)   - State machine + checkpoints            │
├─────────────────────────────────────────────────────────────┤
│  User Memory       - Persistent user profiles               │
│  (persistent)      - Version control + preferences          │
├─────────────────────────────────────────────────────────────┤
│  Knowledge Memory  - RAG document retrieval                 │
│  (persistent)      - Vector search + metadata               │
├─────────────────────────────────────────────────────────────┤
│  Experience Memory - Execution pattern learning             │
│  (long-term)       - Success/failure tracking               │
└─────────────────────────────────────────────────────────────┘

Quick Start

Installation

pip install -e .

Basic Usage

from agent_memory import AgentMemorySystem, MemorySystemConfig

# Configure system
config = MemorySystemConfig(
    redis_url="redis://localhost:6379",
    postgres_url="postgresql://user:pass@localhost/db",
    chroma_path="./chroma_db"
)

# Initialize
system = AgentMemorySystem(config)

# Record conversation
await system.context.add_message(
    user_id="user_123",
    role="user",
    content="Help me analyze Q4 data"
)

# Create tracked task
task = await system.tasks.create_task(
    user_id="user_123",
    goal="Generate Q4 sales report",
    steps=["Collect data", "Analyze", "Generate report"]
)

# Update progress
await system.tasks.complete_step(task.id, 0, {"data": [...]})

# Intelligent retrieval
working_memory = await system.router.retrieve(
    user_id="user_123",
    query="Continue generating the report",
    context={"current_task": task.id}
)

# Format for LLM
prompt = system.injector.format(working_memory)

Core Features

1. Context Memory

Conversation management with token budget control:

from agent_memory.memories import ContextMemory
from agent_memory.models import MessageRole

context = ContextMemory(max_tokens=4000, max_messages=20)

await context.add_message(
    user_id="user_123",
    role=MessageRole.USER,
    content="Hello!"
)

# Get conversation window
window = await context.get_conversation(user_id="user_123")

2. Task Memory

Multi-step task tracking with state management:

from agent_memory.memories import TaskMemory
from agent_memory.models import TaskState

# Create task
task = await task_memory.create_task(
    user_id="user_123",
    goal="Generate report",
    task_type="report_generation"
)

# Update state
await task_memory.start_step(task.id, step_index=0)
await task_memory.complete_step(task.id, 0, result={"status": "done"})

# Get progress
progress = await task_memory.get_progress(task.id)

3. User Memory

Persistent user profiles with preference learning:

from agent_memory.memories import UserMemory

# Learn preference
await user_memory.update_preference(
    user_id="user_123",
    key="response_style",
    value="concise",
    confidence=0.9
)

# Get profile
profile = await user_memory.get_profile("user_123")

4. Knowledge Memory

RAG-based document retrieval:

from agent_memory.memories import KnowledgeMemory

# Index document
await knowledge.index_document(
    doc_id="doc_001",
    content="Document content...",
    metadata={"category": "finance"}
)

# Search
results = await knowledge.search(
    query="Q4 sales",
    top_k=5
)

5. Experience Memory

Pattern learning from execution history:

from agent_memory.memories import ExperienceMemory
from agent_memory.models import ExperienceOutcome

# Record experience
await experience.record(
    task_type="report_generation",
    outcome=ExperienceOutcome.SUCCESS,
    strategy={"steps": [...]},
    lessons=["Validate data first"]
)

# Find similar successful experiences
patterns = await experience.find_patterns(
    task_type="report_generation",
    min_success_rate=0.8
)

Intelligent Routing

The MemoryRouter intelligently selects which memories to load:

from agent_memory.routing import MemoryRouter

router = MemoryRouter(
    context=context,
    tasks=task_memory,
    users=user_memory,
    knowledge=knowledge_memory,
    experience=experience_memory
)

# Automatic feature extraction and routing
working_memory = await router.retrieve(
    user_id="user_123",
    query="Generate Q4 report for East region",
    context={"task_type": "report_generation"}
)

Routing Features

  • Feature Extraction: Automatically detects task complexity, knowledge needs, history
  • Selective Loading: Only loads relevant memory types
  • Importance Scoring: Ranks memories by relevance, recency, frequency
  • Token Budget: Respects context window limits

Importance Scoring

from agent_memory.scoring import ImportanceScorer

scorer = ImportanceScorer(
    relevance_weight=0.3,
    recency_weight=0.25,
    frequency_weight=0.2,
    explicit_weight=0.25
)

score = await scorer.calculate(memory_item, query_context)

Score Components

  • Relevance: Semantic similarity to query
  • Recency: Time decay function
  • Frequency: Access count normalization
  • Explicit: User-rated importance

Storage Backends

Redis (Context & Cache)

from agent_memory.storage import RedisClient

redis = RedisClient(url="redis://localhost:6379")

PostgreSQL (Task, User, Experience)

from agent_memory.storage import PostgresClient

postgres = PostgresClient(url="postgresql://...")

ChromaDB (Knowledge)

from agent_memory.storage import ChromaClient

chroma = ChromaClient(path="./chroma_db")

Configuration

from agent_memory.config import MemorySystemConfig

config = MemorySystemConfig(
    # Redis for context & cache
    redis=RedisConfig(url="redis://localhost:6379"),
    
    # PostgreSQL for structured data
    postgres=PostgreSQLConfig(
        url="postgresql://user:pass@localhost/db"
    ),
    
    # Chroma for vector search
    chroma=ChromaConfig(path="./chroma_db"),
    
    # Memory-specific configs
    context=ContextMemoryConfig(max_tokens=4000),
    tasks=TaskMemoryConfig(),
    users=UserMemoryConfig(),
    knowledge=KnowledgeMemoryConfig(),
    experience=ExperienceMemoryConfig(),
    
    # Scoring config
    scoring=ScoringConfig(
        decay_half_life_days=7.0
    )
)

Project Structure

agent_memory/
├── __init__.py              # System entry point
├── config.py                # Configuration management
├── exceptions.py            # Custom exceptions
├── core/
│   └── base_memory.py       # Abstract base classes
├── memories/                # 5 memory implementations
│   ├── context_memory.py
│   ├── task_memory.py
│   ├── user_memory.py
│   ├── knowledge_memory.py
│   └── experience_memory.py
├── models/                  # Pydantic data models
│   ├── base.py
│   ├── context.py
│   ├── task.py
│   ├── user.py
│   ├── knowledge.py
│   ├── experience.py
│   └── scoring.py
├── routing/                 # Intelligent routing
│   ├── router.py
│   └── feature_extractor.py
├── injection/               # Memory injection
│   ├── injector.py
│   └── formatters.py
├── scoring/                 # Importance scoring
│   ├── importance_scorer.py
│   └── decay.py
└── storage/                 # Backend clients
    ├── redis_client.py
    ├── postgres_client.py
    ├── postgres_models.py
    └── chroma_client.py

tests/                       # Comprehensive test suite
alembic/                     # Database migrations
pyproject.toml              # Project configuration

Dependencies

  • Python 3.10+
  • Redis 5.0+
  • PostgreSQL 14+
  • ChromaDB 0.4+
  • SQLAlchemy 2.0+ (async)
  • Pydantic 2.0+
  • sentence-transformers

Testing

pytest tests/ -v --cov=agent_memory

Migration

alembic upgrade head

Reference

  • Original Article: "如何设计一套Agent长期记忆系统" by Wang Fuqiang
  • Architecture: 5-layer memory with routing and scoring
  • GitHub: laojun509/MemCore
Usage Guidance
This package appears to implement the memory system it advertises, but it silently reads environment variables and a .env file for backend credentials (Redis, PostgreSQL, ChromaDB) even though the registry entry declares no required credentials. Before installing or running: 1) Inspect the storage client files (postgres_client.py, redis_client.py, chroma_client.py) to confirm they only connect to your configured backends and don't call unexpected endpoints. 2) Do not install into an environment that contains production .env secrets or global DB credentials — use an isolated virtualenv or container and test with throwaway databases. 3) Consider whether you want to grant the skill network access to your databases; if not, run it in a sandbox. 4) Because the skill author and homepage are unknown, prefer to audit the source or get the package from a trusted source before giving it real credentials. If you want, I can scan the storage client files (postgres_client.py, redis_client.py, chroma_client.py) and pyproject.toml for any hardcoded hosts or unexpected behavior — that would raise or lower my confidence.
Capability Analysis
Type: OpenClaw Skill Name: agent-memory-enterprise Version: 0.1.0 The agent-memory-enterprise bundle is a legitimate, well-architected implementation of a 5-layer long-term memory system for AI agents, utilizing Redis, PostgreSQL, and ChromaDB. The code follows standard patterns for RAG (Retrieval-Augmented Generation) and state management, including token budget management in 'injector.py' and intelligent routing in 'router.py'. No indicators of malicious intent, data exfiltration, or unauthorized execution were found; the instructions in 'SKILL.md' are consistent with the stated purpose of providing persistent memory capabilities.
Capability Assessment
Purpose & Capability
The name, description, SKILL.md examples, and the included code implement a 5-layer memory system that legitimately requires Redis, PostgreSQL, and ChromaDB configuration. That capability matches the stated purpose. However, the registry metadata lists no required environment variables or primary credential even though the code supports/reads AGENT_MEM_REDIS_URL, AGENT_MEM_POSTGRESQL_URL, AGENT_MEM_CHROMA_PERSIST_DIRECTORY, and similar overrides — a mismatch between declared requirements and actual needs.
Instruction Scope
SKILL.md only shows typical usage and an install hint (pip install -e .) and does not warn that the package will load .env or expect DB connection strings. The code calls dotenv.load_dotenv() and reads environment variables for backend URLs; that means the skill can pick up sensitive credentials from the environment or a .env file without the SKILL metadata declaring those secrets or warning the user.
Install Mechanism
There is no registry install spec, but SKILL.md instructs pip install -e . and the package includes a pyproject and ~50 source files. This is an instruction-only registry entry with embedded code — installing will execute user-supplied code locally. No remote/external download URLs or obfuscated installers were found in the provided files, which lowers supply-chain risk, but the absence of a registry install spec is an inconsistency worth noting.
Credentials
The skill requires backend connection strings (Redis, PostgreSQL, Chroma) to be useful, yet requires.env is empty and primary credential is none. The code reads environment variables (AGENT_MEM_REDIS_URL, AGENT_MEM_POSTGRESQL_URL, AGENT_MEM_CHROMA_PERSIST_DIRECTORY) and will load a .env file via dotenv.load_dotenv(). That means the skill may access secrets present in the environment or a .env file even though the registry did not declare any required credentials — disproportionate lack of disclosure.
Persistence & Privilege
The skill is not marked always:true and does not request system-wide configuration changes in the provided code. It does not appear to modify other skills' configurations. It will, however, attempt to connect to external services (databases, vector DB) when used — expected for its purpose.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install agent-memory-enterprise
  3. After installation, invoke the skill by name or use /agent-memory-enterprise
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v0.1.0
agent-memory-enterprise 0.1.0 - Initial release of an enterprise-grade, 5-layer agent memory system based on Wang Fuqiang’s architecture. - Supports context, task, user, knowledge, and experience memory, each with specialized features for persistent and long-term memory. - Includes smart memory routing, importance scoring, and selective memory retrieval. - Multi-backend storage with PostgreSQL, Redis, and ChromaDB. - Designed for production AI agents needing robust, scalable memory systems.
Metadata
Slug agent-memory-enterprise
Version 0.1.0
License MIT-0
All-time Installs 1
Active Installs 1
Total Versions 1
Frequently Asked Questions

What is Agent Memory Enterprise?

Enterprise-grade 5-layer agent memory system with routing, scoring, and multi-backend storage. Use when building production AI agents that need persistent me... It is an AI Agent Skill for Claude Code / OpenClaw, with 115 downloads so far.

How do I install Agent Memory Enterprise?

Run "/install agent-memory-enterprise" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Agent Memory Enterprise free?

Yes, Agent Memory Enterprise is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Agent Memory Enterprise support?

Agent Memory Enterprise is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Agent Memory Enterprise?

It is built and maintained by laojun (@laojun509); the current version is v0.1.0.

💬 Comments