Skip to content
Navigation

Pluggable memory backends for short-term, long-term, and vector-based memory storage.

Module Path

code
orbiter.memory

Installation

bash
pip install "orbiter-memory @ git+https://github.com/Midsphere-AI/orbiter-ai.git#subdirectory=packages/orbiter-memory"

Overview

The orbiter-memory package provides a memory system for agents with:

  • MemoryStore protocol — pluggable backend interface for add/get/search/clear
  • Typed memory itemsSystemMemory, HumanMemory, AIMemory, ToolMemory with status lifecycle
  • ShortTermMemory — in-memory conversation store with scope filtering and windowing
  • LongTermMemory — persistent knowledge with deduplication and LLM-powered extraction
  • Summary system — configurable triggers and multi-template summarization
  • Event integrationMemoryEventEmitter wraps any store with EventBus events
  • Backend implementations — SQLite, Postgres, and Vector (embedding-based) stores

Exports

ExportTypeDescription
MemoryStoreProtocolPluggable backend interface
MemoryItemPydantic modelBase memory entry
MemoryMetadataPydantic modelScoping metadata
MemoryStatusStrEnumItem lifecycle status
MemoryErrorExceptionMemory operation errors
SystemMemoryPydantic modelSystem/initialization memory
HumanMemoryPydantic modelUser message memory
AIMemoryPydantic modelAI response memory
ToolMemoryPydantic modelTool result memory
ShortTermMemoryClassIn-memory conversation store
LongTermMemoryClassPersistent knowledge store
ExtractorProtocolLLM extraction interface
ExtractionTypeStrEnumKnowledge extraction categories
ExtractionTaskDataclassExtraction task tracking
TaskStatusStrEnumExtraction task lifecycle
MemoryOrchestratorClassAsync extraction orchestrator
OrchestratorConfigDataclassOrchestrator settings
SummarizerProtocolLLM summarization interface
SummaryConfigDataclassSummary trigger/generation settings
SummaryResultDataclassSummary generation output
SummaryTemplateStrEnumBuilt-in summary templates
check_triggerFunctionCheck if summary should be generated
generate_summaryFunctionGenerate summaries from items
MemoryEventEmitterClassEventBus-integrated store wrapper
MEMORY_ADDEDstrEvent constant: "memory:added"
MEMORY_SEARCHEDstrEvent constant: "memory:searched"
MEMORY_CLEAREDstrEvent constant: "memory:cleared"

Import Patterns

python
# Common imports
from orbiter.memory import (
    MemoryStore, MemoryItem, MemoryMetadata, MemoryStatus,
    ShortTermMemory, LongTermMemory,
    HumanMemory, AIMemory, SystemMemory, ToolMemory,
)

# Summary system
from orbiter.memory import (
    SummaryConfig, SummaryTemplate, SummaryResult,
    Summarizer, check_trigger, generate_summary,
)

# Backends (import directly from submodules)
from orbiter.memory.backends.sqlite import SQLiteMemoryStore
from orbiter.memory.backends.postgres import PostgresMemoryStore
from orbiter.memory.backends.vector import VectorMemoryStore, Embeddings, OpenAIEmbeddings

Quick Example

python
import asyncio
from orbiter.memory import (
    ShortTermMemory, HumanMemory, AIMemory, MemoryMetadata,
)

async def main():
    memory = ShortTermMemory(scope="session", max_rounds=10)

    meta = MemoryMetadata(user_id="user-1", session_id="sess-1")

    await memory.add(HumanMemory(content="Hello!", metadata=meta))
    await memory.add(AIMemory(content="Hi there!", metadata=meta))

    results = await memory.search(metadata=meta, limit=5)
    for item in results:
        print(f"[{item.memory_type}] {item.content}")

asyncio.run(main())

See Also

  • base — MemoryStore protocol and typed items
  • short-term — ShortTermMemory
  • long-term — LongTermMemory and orchestrator
  • summary — Summary system
  • events — MemoryEventEmitter
  • backends — SQLite, Postgres, Vector stores