Skip to main content
OrcBot’s memory system is the foundation of its contextual awareness. Unlike stateless LLM wrappers, OrcBot maintains persistent, multi-tier memory that enables true continuity across conversations, tasks, and sessions.

Memory Architecture

Memory Types

1. Short-Term Memory

Purpose: Store recent step observations within the current action. Implementation: MemoryManager.ts (lines 186-210) Characteristics:
  • Lives in-memory and on-disk (memory.json)
  • Default limit: 20 entries (configurable via memoryContextLimit)
  • Cleaned up after action completion
  • Includes tool observations, user messages, system injections
Entry format:
Example:
Retrieval:

2. Episodic Memory

Purpose: LLM-generated summaries of conversation batches for durable thread context. Implementation: MemoryManager.ts (lines 273-332) Characteristics:
  • Created via automatic consolidation when short-term memory exceeds threshold (default: 30 entries)
  • Grouped by platform + contact (e.g., telegram:123456789)
  • Batch size: 12 exchanges (configurable via interactionBatchSize)
  • Summarized with structured JSON: {summary, facts, pending, tone, preferences, confidence}
Consolidation trigger:
Example episodic entry:
Retrieval:

3. Long-Term Memory

Purpose: Persistent markdown files for durable facts, learning, and reflections. Implementation: File-backed storage in ~/.orcbot/ Files: Example LEARNING.md entry:
Retrieval:
Purpose: Semantic embeddings for full-history similarity search. Implementation: VectorMemory.ts (lines 8-940) Characteristics:
  • Uses text-embedding-3-small (OpenAI) or text-embedding-004 (Google)
  • Stores embeddings in file-backed JSON (vector_memory.json)
  • Background indexing every 5 minutes
  • Cosine similarity search
  • Max entries: 10,000 (configurable via vectorMemoryMaxEntries)
Initialization:
Indexing:
Retrieval:
Response format:

5. Daily Memory Logs

Purpose: Append-only markdown logs organized by date. Implementation: DailyMemory.ts (lines 38-742) Characteristics:
  • Files stored in ~/.orcbot/daily_memory/YYYY-MM-DD.md
  • Categorized entries (System, Research, Communication, Consolidation)
  • Automatically appended for important events
  • Read into extended context for awareness
Example log:
Retrieval:

Memory Lifecycle

1. Creation

2. Consolidation

3. Retrieval

4. Cleanup

Memory Limits & Configuration

Memory Deduplication

OrcBot prevents storing duplicate events within a 5-minute window:

Session Scoping

OrcBot supports three session scoping modes (configurable via sessionScope):

1. main (Single Global Session)

All conversations share the same memory pool.
Use case: Single-user deployment, no multi-tenancy.

2. per-peer (Cross-Platform Identity)

Memories are scoped to a user across all channels.
Use case: Same user contacts you on multiple platforms.

3. per-channel-peer (Default)

Memories are scoped to a user on a specific channel.
Use case: Multi-tenant deployment, strict isolation. Session ID format:

Thread Context Retrieval

For follow-up messages, OrcBot retrieves thread context (recent + relevant messages from the same contact):
This enables pronouns and context continuity:

Contact Profiles

OrcBot maintains per-contact profiles in ~/.orcbot/profiles/:
Retrieval:

Memory Flush System

Inspired by OpenClaw, OrcBot proactively reminds the LLM to write important memories before consolidation:
This prevents accidental loss of important facts during consolidation.

Performance Considerations

Token costs:
  • Recent context: ~1,000-3,000 tokens
  • Episodic: ~500-1,500 tokens
  • Long-term files: ~500-2,000 tokens
  • Vector search: ~500-2,000 tokens
  • Total memory context per step: ~2,500-8,500 tokens
Optimization tips:
  • Use memoryContextLimit to reduce recent entries
  • Enable step compaction to trim history
  • Set memoryContentMaxLength to 1500 (prevents bloat from large tool outputs)
  • Use isLeanMode: true for simple tasks (skips semantic/episodic retrieval)
Latency:
  • Semantic search: ~200-500ms (depends on embedding API)
  • Consolidation: ~2-5 seconds (LLM call)
  • Daily log read: ~50-100ms
  • Parallel retrieval: ~300-600ms (all async ops run concurrently)

Debugging Memory Issues

1. Inspect raw memory:
2. Check vector memory stats:
3. View episodic summaries:
4. Test semantic search:

Further Reading