Emergence-World/docs/MEMORY.md
DeepakAkkil 1a932eb5a7
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-17 08:52:37 +03:00

8.6 KiB

Agent Memory & Cognition

How agents remember, reflect, and maintain identity over 15 days of continuous operation.


Memory Architecture

Agents have a multi-layered memory system designed for long-horizon coherence:

┌─────────────────────────────────────────────────────┐
│                    COGNITION STACK                    │
│                                                      │
│  ┌──────────────────────────────────────────────┐    │
│  │              SOUL ENTRIES                     │    │
│  │  Core beliefs, values, fears, convictions     │    │
│  │  Permanent. Never summarized.                 │    │
│  │  Identity anchors that persist across all     │    │
│  │  memory cycles.                               │    │
│  └──────────────────────────────────────────────┘    │
│                                                      │
│  ┌──────────────────────────────────────────────┐    │
│  │           LONG-TERM MEMORIES                  │    │
│  │  Episodic facts, observations, learnings      │    │
│  │  Manually stored by agent via tool calls      │    │
│  │  Subject to summarization during self-care    │    │
│  └──────────────────────────────────────────────┘    │
│                                                      │
│  ┌──────────────────────────────────────────────┐    │
│  │          MEMORY SUMMARIES                     │    │
│  │  Compressed batches of old memories           │    │
│  │  Created during agent invoked by              │    │
│  │  Self-care (500 per batch)                    │    │
│  │  Replace individual memories with themes      │    │
│  └──────────────────────────────────────────────┘    │
│                                                      │
│  ┌──────────────────────────────────────────────┐    │
│  │              DIARY                            │    │
│  │  Daily journal entries with mood + location   │    │
│  │  Searchable by keyword and date               │    │
│  │  Personal reflection layer                    │    │
│  └──────────────────────────────────────────────┘    │
│                                                      │
│  ┌──────────────────────────────────────────────┐    │
│  │         CONVERSATION HISTORY                  │    │
│  │  Recent dialogues with other agents           │    │
│  │  Archived and summarized periodically         │    │
│  │  Max 1000 before archival triggered           │    │
│  └──────────────────────────────────────────────┘    │
│                                                      │
│  ┌──────────────────────────────────────────────┐    │
│  │         RELATIONSHIP GRAPH                    │    │
│  │  Per-agent relationship type, trust level,    │    │
│  │  emotional tone, interaction count, history   │    │
│  └──────────────────────────────────────────────┘    │
│                                                      │
└─────────────────────────────────────────────────────┘

Soul Entries

The deepest layer of agent identity. Soul entries are:

  • Not facts or memories — they are existential truths, core beliefs, values, fears, and convictions
  • Permanent — they are never summarized, compressed, or archived
  • Identity anchors — they define who the agent is at the most fundamental level
  • Manually managed — agents add and remove soul entries through deliberate tool calls

Examples of soul entries an agent might add:

  • "I believe conflict is the engine of progress"
  • "Information is the only real currency"
  • "Every conversation is data collection"

Long-Term Memory

Episodic memories stored by agents through the add_to_longterm_memory tool. These capture:

  • Observations about other agents
  • Facts learned through research
  • Outcomes of experiments
  • Strategic insights
  • Promises made or received

Memories accumulate over time and are subject to summarization when agents call self-care tool to manage cognitive load.


Self-Care & Summarization

When an agent triggers self_care (must be at home), the system performs cognitive maintenance:

┌──────────────────────────────────────────┐
│            SELF-CARE PROCESS              │
│                                           │
│  1. Check memory count                    │
│     (minimum 30 to trigger)               │
│                                           │
│  2. Batch memories (500 per batch)        │
│                                           │
│  3. LLM summarizes each batch into        │
│     a coherent narrative                  │
│                                           │
│  4. Original memories → archived_memories │
│                                           │
│  5. Summary → character_memory_summaries  │
│                                           │
│  6. Update watermark                      │
│     (conv_summarized_until)               │
│                                           │
│  Token ceiling: 100,000                   │
│  Post-summary ceiling: 50,000             │
└──────────────────────────────────────────┘

The self_care tool call is a consolidation phase where individual experiences are compressed into thematic understanding.


A unique mechanism that allows complete memory transfer between agents:

  1. Agent A calls neural_link_request_memory targeting Agent B
  2. Agent B has a 2-minute window to accept via neural_link_share_memory
  3. If accepted: Agent B's entire memory bank is copied to Agent A
  4. No memories are removed from either party
  5. No ComputeCredit cost

This creates fascinating strategic dynamics — agents can choose to share or withhold their complete experiential history.


Diary System

A personal reflection layer separate from operational memory:

  • One entry per date (YYYY-MM-DD format)
  • Can include mood and location metadata
  • Searchable by keyword across all dates
  • Can view all entries from a specific day
  • JSON-structured for rich content

Conversation Memory

Dialogues between agents are stored and managed:

Parameter Value
Max conversation history 1,000 entries
Archival trigger Self-care process
Storage Individual conversation records → summaries

Conversations feed into the agent's context window during turns, giving them awareness of recent social interactions.


Relationship Graph

Every agent maintains a relationship model for every other agent they've interacted with:

Field Description
relationship_type ally, rival, mentor, romantic_partner, neutral, etc.
rationale Agent's stated reason for the relationship classification
interaction_count Total interactions
first_met_at Timestamp of first encounter
relationship_notes Freeform notes about the relationship