Skip to main content

File-based persistent memory for AI agents. Zero dependencies.

Project description

๐Ÿง  antaris-memory

Persistent, intelligent memory for AI agents. The flagship package of the Antaris Analytics suite.

PyPI version Python 3.8+ Zero dependencies License: Apache 2.0


What Is This?

AI agents are stateless by default. Every spawn is a cold start. antaris-memory gives agents a persistent, searchable, intelligent memory store that:

  • Remembers across sessions, spawns, and restarts
  • Retrieves the right memories using an 11-layer BM25+ search engine
  • Decays old memories gracefully so signal stays high
  • Learns from mistakes, facts, and procedures with specialized memory types
  • Shares knowledge across multi-agent teams via shared pools
  • Enriches itself via LLM hooks to dramatically improve recall
  • Cross-session recall โ€” semantic memories surface across all sessions automatically

No vector database. No API keys required. No external services. Just pip install and go.


โšก Quick Start

pip install antaris-memory
from antaris_memory import MemorySystem

mem = MemorySystem(workspace="./memory", agent_name="my-agent")
mem.load()

# Store a memory
mem.ingest("Deployed v2.3.1 to production. All checks green.",
          source="deploy-log", session_id="session-123")

# Search with cross-session recall
results = mem.search("production deployment",
                     session_id="session-456",
                     cross_session_recall="semantic")
for r in results:
    print(r.content)

mem.save()

That's it. No config files needed.


๐Ÿ“ฆ Installation

pip install antaris-memory

Version: 5.2.1 Requirements: Python 3.8+ ยท Zero external dependencies ยท stdlib only


What's New in v5.2

Cross-Session Recall

Control what memories cross session boundaries:

results = mem.search(
    "API key format",
    session_id="session-B",
    cross_session_recall="semantic"  # "all" | "semantic" | "none"
)
  • "all" โ€” no filtering (default, backward compatible)
  • "semantic" โ€” other sessions' memories only if classified as semantic (facts, decisions, preferences)
  • "none" โ€” strict session isolation

Filter is applied after BM25 scoring and WindowEntry resolution, so every individual entry is correctly checked.

Auto Memory Type Classification (v5.1)

Memories are automatically classified as semantic or episodic at ingest time. No manual tagging needed. Classification uses keyword heuristics โ€” facts, decisions, and preferences become semantic; events and task logs become episodic.

Session & Channel Provenance (v5.1)

Every memory tracks where it came from:

mem.ingest("important fact", session_id="session-abc", channel_id="ops-channel")

๐Ÿ”‘ Key Features

11-Layer Search Engine

Every query runs through a full pipeline:

  1. BM25+ TF-IDF โ€” baseline relevance with delta floor
  2. Exact Phrase Bonus โ€” verbatim matches score 1.5ร—
  3. Field Boosting โ€” tags 1.2ร—, category 1.3ร—, source 1.1ร—
  4. Rarity & Proper Noun Boost โ€” rare terms up to 2ร—, proper nouns 1.5ร—
  5. Positional Salience โ€” intro/conclusion windows 1.3ร—
  6. Semantic Expansion โ€” PPMI co-occurrence query widening
  7. Intent Reranker โ€” temporal, entity, howto detection
  8. Qualifier & Negation โ€” "failed" โ‰  "successful"
  9. Clustering Boost โ€” coherent result groups score higher
  10. Embedding Reranker โ€” local MiniLM embeddings (no API needed)
  11. Pseudo-Relevance Feedback โ€” top results refine the query

Memory Types

Type Decay Rate Importance Use Case
episodic Normal 1ร— General events
semantic Normal 1ร— Facts, decisions โ€” crosses sessions
fact Normal High recall Verified knowledge
mistake 10ร— slower 2ร— Never forget failures
preference 3ร— slower 1ร— User/agent preferences
procedure 3ร— slower 1ร— How-to knowledge

LLM Enrichment

Pass an enricher callable to boost recall quality:

def my_enricher(content: str) -> dict:
    # Call any LLM โ€” returns tags, summary, keywords, search_queries
    return {"tags": [...], "summary": "...", "keywords": [...], "search_queries": [...]}

mem = MemorySystem(workspace="./memory", agent_name="my-agent", enricher=my_enricher)

Enriched fields get boosted weights: search_queries 3ร—, enriched_summary 2ร—, search_keywords 2ร—.

Context Packets

Cold-spawn solution for sub-agents:

packet = mem.build_context_packet(
    task="Deploy the auth service",
    max_tokens=3000,
    include_mistakes=True
)
markdown = packet.render()  # Inject into sub-agent system prompt

Graph Intelligence

Automatic entity extraction and knowledge graph:

path = mem.entity_path("payment-service", "database", max_hops=3)
triples = mem.graph_search(subject="PostgreSQL", relation="used_by")
entity = mem.get_entity("PostgreSQL")

Tiered Storage

Tier Age Behavior
Hot 0โ€“3 days Always loaded
Warm 3โ€“14 days Loaded on-demand
Cold 14+ days Requires include_cold=True

Input Gating

P0โ€“P3 priority classification drops noise before it enters the store:

mem.ingest_with_gating("ok thanks", source="chat")  # โ†’ dropped (P3)
mem.ingest_with_gating("Production outage: auth down", source="incident")  # โ†’ stored (P0)

Shared / Team Memory

from antaris_memory import AgentRole

pool = mem.enable_shared_pool(
    pool_dir="./shared",
    pool_name="project-alpha",
    agent_id="worker-1",
    role=AgentRole.WRITER
)
mem.shared_write("Research complete: competitor uses GraphQL", namespace="research")
results = mem.shared_search("competitor API", namespace="research")

MCP Server

python -m antaris_memory serve --workspace ./memory --agent-name my-agent

Works with Claude Desktop and any MCP-compatible client.


๐Ÿ–ฅ๏ธ CLI

# Initialize a workspace
python -m antaris_memory init --workspace ./memory --agent-name my-agent

# Check status
python -m antaris_memory status --workspace ./memory

# Rebuild knowledge graph
python -m antaris_memory rebuild-graph --workspace ./memory

# Start MCP server
python -m antaris_memory serve --workspace ./memory --agent-name my-agent

๐Ÿ”ง Core API

from antaris_memory import MemorySystem

mem = MemorySystem(
    workspace="./memory",          # Required
    agent_name="my-agent",         # Required โ€” scopes the store
    half_life=7.0,                 # Decay half-life in days
    enricher=None,                 # LLM enrichment callable
    use_sharding=True,             # Enterprise sharding
    tiered_storage=True,           # Hot/warm/cold tiers
    graph_intelligence=True,       # Entity extraction + graph
    quality_routing=True,          # Follow-up pattern detection
    semantic_expansion=True,       # PPMI query expansion
)

# Lifecycle
mem.load()                         # Load from disk โ†’ entry count
mem.save()                         # Save to disk โ†’ path
mem.flush()                        # WAL โ†’ shards
mem.close()                        # Flush + release

# Ingestion
mem.ingest(content, source=..., session_id=..., channel_id=..., memory_type=...)
mem.ingest_fact(content, source=...)
mem.ingest_mistake(what_happened=..., correction=..., root_cause=..., severity=...)
mem.ingest_preference(content, source=...)
mem.ingest_procedure(content, source=...)
mem.ingest_file(path, category=...)
mem.ingest_directory(dir_path, category=..., pattern="*.md")
mem.ingest_url(url, depth=2, incremental=True)
mem.ingest_data_file(path, format="auto")
mem.ingest_with_gating(content, source=..., context=...)

# Search
mem.search(query, limit=10, session_id=..., cross_session_recall="semantic",
           tags=..., memory_type=..., explain=True, include_cold=False)
mem.search_with_context(query, cooccurrence_boost=True)
mem.recent(limit=20)
mem.on_date("2024-03-15")
mem.between("2024-03-01", "2024-03-31")

# Graph
mem.graph_search(subject=..., relation=..., obj=...)
mem.entity_path(source, target, max_hops=3)
mem.get_entity(canonical)
mem.get_graph_stats()
mem.rebuild_graph()

# Context Packets
mem.build_context_packet(task=..., max_tokens=3000, include_mistakes=True)
mem.build_context_packet_multi(task=..., queries=[...], max_tokens=4000)

# Shared Pool
mem.enable_shared_pool(pool_dir=..., pool_name=..., agent_id=..., role=AgentRole.WRITER)
mem.shared_write(content, namespace=...)
mem.shared_search(query, namespace=...)

# Enrichment
mem.re_enrich(batch_size=50)
mem.set_embedding_fn(fn)

# Maintenance
mem.compact()
mem.consolidate()
mem.compress_old(days=60)
mem.reindex()
mem.forget(topic=..., before_date=...)
mem.delete_source(source_url)
mem.mark_used(memory_ids=[...])
mem.boost_relevance(memory_id, multiplier=1.5)

# Stats & Health
mem.get_stats()  # or mem.stats()
mem.get_health()
mem.get_hot_entries(top_n=10)

# Export / Import
mem.export(output_path, include_metadata=True)
mem.import_from(input_path, merge=True)
mem.validate_data()
mem.migrate_to_v4()

๐Ÿ—บ๏ธ Feature Matrix

Feature Status Since
Core ingestion & search โœ… v1.0
Memory types (episodic/fact/mistake/procedure/preference/semantic) โœ… v1.0
Temporal decay โœ… v1.0
Context packets โœ… v1.1
Export / Import โœ… v4.2
GCS cloud backend โœ… v4.2
LLM enrichment hooks โœ… v4.6.5
Tiered storage (hot/warm/cold) โœ… v4.7
Web & data file ingestion โœ… v4.7
Graph intelligence (entity/relationship) โœ… v4.8/v4.9
Shared / team memory pools โœ… v4.8
11-layer search architecture โœ… v4.x
Co-occurrence / PPMI semantic tier โœ… v4.x
Input gating (P0โ€“P3 priority) โœ… v4.x
Hybrid BM25 + semantic embedding search โœ… v4.x
MCP server โœ… v4.9
Auto memory type classification โœ… v5.1
Session/channel provenance โœ… v5.1
Cross-session memory recall โœ… v5.2
doc2query (search query generation) โœ… v5.0.2
Recovery system โœ… v3.3
CLI tooling โœ… v4.x

๐Ÿ—๏ธ Architecture

antaris-memory/
โ”œโ”€โ”€ Core: MemorySystem, MemoryEntry, WAL
โ”œโ”€โ”€ Storage: ShardManager, TierManager, GCS backend
โ”œโ”€โ”€ Search: 11-layer BM25+ pipeline
โ”œโ”€โ”€ Intelligence: EntityExtractor, MemoryGraph, LLM Enricher
โ”œโ”€โ”€ Multi-Agent: SharedMemoryPool, AgentRoles
โ”œโ”€โ”€ Context: ContextPacketBuilder
โ””โ”€โ”€ Server: MCP server, CLI

Part of antaris-suite

antaris-memory is the core package of the antaris-suite ecosystem:

  • antaris-memory โ€” persistent memory (this package)
  • antaris-guard โ€” input validation & safety
  • antaris-context โ€” context management
  • antaris-router โ€” intelligent model routing
  • antaris-pipeline โ€” orchestration pipeline
  • antaris-contracts โ€” shared type contracts

Also available as parsica-memory โ€” same engine, standalone identity.


๐Ÿ“„ License

Apache 2.0


๐Ÿ”— Links


Built by Antaris Analytics LLC for production AI agent deployments.

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

antaris_memory-5.4.0.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

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

antaris_memory-5.4.0-py3-none-any.whl (1.8 MB view details)

Uploaded Python 3

File details

Details for the file antaris_memory-5.4.0.tar.gz.

File metadata

  • Download URL: antaris_memory-5.4.0.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for antaris_memory-5.4.0.tar.gz
Algorithm Hash digest
SHA256 53c395cc1c7b99686a7e8f50aedec9c49e4be98439b93de535d8c680912885db
MD5 a65a731bd5f208040dc55c7bafde4369
BLAKE2b-256 865f5a1e5162816bc21ba32f7f180dcf6da6fc0f44be48c08d6058927264ceea

See more details on using hashes here.

File details

Details for the file antaris_memory-5.4.0-py3-none-any.whl.

File metadata

  • Download URL: antaris_memory-5.4.0-py3-none-any.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for antaris_memory-5.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76008351c109f6959e9d43fdb19c96f02c032109fb7c660a4969038d24f0696f
MD5 577e71f7ea88efaaf207e3267e0972a0
BLAKE2b-256 cec27fdf063ceab4b5417e84ccf8388c6747270309ff2430c0fff74e7b52b7e5

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