Memory Layer

The Memory Layer provides persistent, personalized context for KEK's AI agents. It enables agents to remember past interactions, track evolving facts over time, and personalize recommendations across sessions.

Memory is an input to intelligence — not an execution trigger.

What this page covers

  • The purpose of the Memory Layer in KEK
  • How Mem0 provides user and agent memory
  • How Graphiti provides temporal knowledge graphs
  • Integration with the MCP Agent Server
  • What the Memory Layer does and does not do

Purpose of the Memory Layer

Trading AI systems face a fundamental challenge: fixed context windows limit how much history and preference data can inform each decision. The Memory Layer solves this by intelligently extracting, consolidating, and retrieving relevant context.

This enables:

  • Personalization — Strategies informed by user risk preferences and past behavior
  • Temporal reasoning — Understanding how facts and relationships evolve over time
  • Cross-session continuity — Context that persists across conversations and trading sessions
  • Agent coordination — Shared memory across specialized agents (Regime, Narrative, Strategy)

The Memory Layer does not execute trades, allocate capital, or override validation requirements.

Mem0: User and agent memory

Mem0 is a universal memory layer that enables personalized AI interactions across sessions. Rather than storing raw conversation history, Mem0 uses LLMs to extract and consolidate salient facts.

How Mem0 works

  • Intelligent extraction — LLMs identify important facts from conversations (not raw message storage)
  • Memory consolidation — New memories are evaluated against existing ones to prevent redundancy
  • Fast retrieval — Sub-50ms latency for real-time agent augmentation
  • Scoped organization — Memories organized by user, agent, and session

Memory scoping in KEK

Mem0 organizes memories hierarchically:

  • User memory — Trader preferences, risk tolerance, past strategy outcomes, asset interests
  • Agent memory — Strategy-specific learnings, performance patterns, market condition responses
  • Session memory — Current trading context, in-flight decisions, active conversations

This scoping ensures agents receive relevant context without information overload.

Example use cases

  • Remembering that a trader prefers conservative leverage (2x max)
  • Recalling which strategy variants performed well under volatile conditions
  • Personalizing alerts based on past acknowledged warnings
  • Tracking which asset classes the user has shown interest in

Mem0 provides recall — not prediction. All memory-informed recommendations flow through validation.

Graphiti: Temporal knowledge graphs

Graphiti (by Zep AI) provides a temporal knowledge graph that captures evolving facts and relationships over time. Unlike static knowledge bases, Graphiti understands when facts became true, when they changed, and how entities relate across time.

How Graphiti works

  • Bi-temporal model — Tracks both event time (when facts occurred) and transaction time (when recorded)
  • Episodic memory — Raw events preserved with original timestamps (non-lossy)
  • Semantic extraction — Entities and relationships extracted from episodes
  • Temporal queries — "What did we know about X on date Y?"
  • Conflict resolution — Automatically invalidates outdated facts when new information arrives

Three-tier memory architecture

Graphiti organizes knowledge hierarchically:

Episodic subgraph

  • Raw events: trade executions, market data, user interactions
  • High-fidelity, timestamped, non-lossy preservation
  • Source of truth for all downstream processing

Semantic entity subgraph

  • Extracted entities: assets, strategies, market regimes, risk factors
  • Relationships with temporal validity intervals
  • Enables pattern recognition across episodes

Community subgraph

  • Clusters of semantically related entities
  • Higher-order patterns emerge from relationships
  • Reduces traversal complexity for large graphs

Example use cases

  • Tracking how a strategy's performance evolved across different market regimes
  • Understanding when a correlation pattern between assets emerged and changed
  • Reconstructing the decision context at the time a strategy was validated
  • Detecting when prior assumptions about market behavior became invalid

Graphiti provides structured memory for temporal reasoning — not trade execution.

Integration with MCP Agent Server

Both memory systems feed into the MCP Agent Server, which orchestrates KEK's specialized AI agents.

Data flow:

  1. User interactions and preferences are captured by Mem0
  2. Market events and facts are ingested by Graphiti
  3. MCP Agent Server queries both systems for relevant context
  4. Agents receive augmented context for strategy generation
  5. Generated strategies flow to validation (backtesting, paper trading)
  6. Outcomes feed back into memory for continuous learning

Memory augments agent intelligence but does not bypass validation gates.

Performance characteristics

Both memory systems are optimized for real-time agent augmentation:

  • Mem0 retrieval — Sub-50ms latency (p95)
  • Graphiti queries — Sub-100ms typical
  • Memory consolidation — Automatic deduplication and conflict resolution
  • Scalability — Designed for high-volume agent interactions

These characteristics enable memory-augmented decisions without introducing latency bottlenecks.

What the Memory Layer does not do

The Memory Layer does not:

  • Execute trades or allocate capital
  • Store private keys or access user funds
  • Override validation requirements
  • Guarantee strategy performance based on past patterns
  • Replace the Knowledge Network's structured intelligence

Memory is infrastructure for context — not a prediction engine.

Why this matters

The Memory Layer enables KEK to:

  • Reduce context loss — Important facts persist across sessions and conversations
  • Improve personalization — Strategies adapt to observed user preferences
  • Enable temporal reasoning — Agents understand how facts and relationships evolve
  • Support auditability — Complete historical record for compliance and debugging
  • Maintain validation discipline — Memory informs but does not override

KEK treats memory as infrastructure for better intelligence — not as a shortcut to execution.

Where to go next