Skip to main content

Add your description here

Project description

MemoryAgent

MemoryAgent: An Open, Modular Memory Framework for Agents (Beta)

MemoryAgent is a reusable memory framework for LLM-based agent systems. It provides tiered memory (working, episodic, semantic, perceptual), hot/cold storage, archive indexing, confidence-based retrieval escalation, and optional local vector search via sqlite-vec.

Highlights

  • Tiered memory: working (TTL), episodic, semantic, perceptual
  • Storage tiers: hot metadata (SQLite + sqlite-vec), cold archive (filesystem), archive index (vector index)
  • Memory retrieval pipeline: hot -> archive -> cold hydration with rerank + context packaging
  • Local mode: SQLite + sqlite-vec (optional) + filesystem
  • Async-friendly with sync convenience methods

Project Layout

memoryagent/
  config.py            # Default system settings and retrieval thresholds
  models.py            # Pydantic data models for memory items, queries, bundles
  system.py            # MemorySystem entry point and wiring
  retrieval.py         # Retrieval orchestration and reranking
  confidence.py        # Confidence scoring components
  policy.py            # Conversation + routing policies
  indexers.py          # Episodic/semantic/perceptual indexers
  workers.py           # Consolidation, archiving, rehydration, compaction
  storage/
    base.py            # Storage adapter interfaces
    in_memory.py       # Simple in-memory vector + graph stores
    local_disk.py      # SQLite metadata/features + sqlite-vec + file object store
  examples/
    minimal.py         # Basic usage example
    openai_agent.py    # CLI OpenAI agent with memory retrieval
    memory_api_server.py # Local API for memory + chat
    memory_viz.html    # Web UI for chat + memory visualization

Installation

Python 3.10+ required.

Development (sync deps from uv.lock):

uv sync

Use as a dependency:

uv add memoryagent-lib
# or
pip install memoryagent-lib

Optional extras:

uv add openai sqlite-vec
# or
pip install openai sqlite-vec

Quick Start

from memoryagent import MemoryEvent, MemorySystem

memory = MemorySystem()
owner = "user-001"

memory.write(
    MemoryEvent(
        content="User prefers concise summaries about climate policy.",
        type="semantic",
        owner=owner,
        tags=["preference", "summary"],
        confidence=0.7,
        stability=0.8,
    )
)

bundle = memory.retrieve("What policy topics did we cover?", owner=owner)
print(bundle.confidence.total)
for block in bundle.blocks:
    print(block.text)

memory.flush(owner)

Enable sqlite-vec (Local Vector Search)

from memoryagent import MemorySystem, MemorySystemConfig

config = MemorySystemConfig(
    use_sqlite_vec=True,
    vector_dim=1536,  # match your embedding model
)

memory = MemorySystem(config=config)

If sqlite-vec cannot be auto-loaded, set an explicit path:

from pathlib import Path
from memoryagent import MemorySystemConfig

config = MemorySystemConfig(
    use_sqlite_vec=True,
    vector_dim=1536,
    sqlite_vec_extension_path=Path("/path/to/sqlite_vec.dylib"),
)

Policies

Conversation storage policy

HeuristicMemoryPolicy decides whether a turn should be stored and whether it becomes episodic or semantic memory.

Routing policy

MemoryRoutingPolicy decides where a memory should be written:

  • Hot metadata store
  • Vector index
  • Feature store (perceptual)
  • Cold archive (via workers)

Background Workers

  • ConsolidationWorker: working → episodic/semantic
  • ArchiverWorker: hot → cold + archive index
  • RehydratorWorker: cold → hot (based on access)
  • Compactor: cleanup/TTL

Examples

OpenAI Agent (CLI)

python -m memoryagent.examples.openai_agent
  • Uses OpenAI responses + embeddings.
  • Stores session transcript as a single working memory item.

Memory Visualization + API

Start the API server:

python -m memoryagent.examples.memory_api_server

Open in browser:

http://127.0.0.1:8000/memory_viz.html

An example (System records semantic memory and updating working memory):

Screenshot

The page calls:

  • GET /api/memory?owner=user-001
  • POST /api/chat

Data Stores

  • Hot metadata: .memoryagent_hot.sqlite
  • Vector index: .memoryagent_vectors.sqlite (sqlite-vec)
  • Features: .memoryagent_features.sqlite
  • Cold archive: .memoryagent_cold/records/<owner>/YYYY/MM/DD/daily_notes.json

Configuration

See memoryagent/config.py for defaults:

  • working_ttl_seconds
  • retrieval_plan thresholds and budgets
  • use_sqlite_vec, vector_dim, sqlite_vec_extension_path

Notes

  • Working memory is stored as a single session transcript (updated each turn).
  • Episodic/semantic memories are candidates for cold archive.

License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memoryagent_lib-0.1.1.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

memoryagent_lib-0.1.1-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

File details

Details for the file memoryagent_lib-0.1.1.tar.gz.

File metadata

  • Download URL: memoryagent_lib-0.1.1.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for memoryagent_lib-0.1.1.tar.gz
Algorithm Hash digest
SHA256 735425c09fe6b709cb07b3553963894ecacc0a9f26aa9a61d831ee225637190f
MD5 8b2dc1b8e6006ac74fad9dc37f4b3ff6
BLAKE2b-256 af7e3e91a46eae62ddc900a50f9353d3cea41ab302ac55f38fd69d4ba233078d

See more details on using hashes here.

File details

Details for the file memoryagent_lib-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for memoryagent_lib-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 be1715bd6abce44fadd9ce862cd73b765ec46c80486347dd0b73f8af223af65b
MD5 e32202984dfe96e860d5f55dc97135e2
BLAKE2b-256 ff5cb88d782bb4c80066697b1d47c682c33d2124d03075e3d22125cca6e05e23

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page