Skip to content

v0.7: Memory Manager And Owner Model [PARTIAL]

Implementation Status

  • [x] MemoryStore exists and manages markdown memory plus FACTS.md.
  • [x] remember, recall, and update_profile tools use the current memory store.
  • [x] ContextBuilder retrieves relevant memory before prompt assembly.
  • [x] g_agent/memory/manager.py exists.
  • [x] MemoryManager and MemoryProvider first slice exists.
  • [x] Provider registration/order/failure isolation implemented with tests.
  • [x] Memory prefetch is formalized through a manager with fenced output.
  • [ ] External memory provider selection is not implemented.
  • [ ] Memory write cadence hooks are not fully wired.

Goal

Create durable character memory without prompt bloat.

User Outcome

The character can remember owner facts, preferences, people, relationships, projects, routines, environment quirks, and character reflections without stuffing every memory into every prompt.

Scope

  • Add built-in local memory provider.
  • Add context fencing so recalled memory is never treated as new user input.
  • Add pre-turn recall and post-turn sync lifecycle hooks.
  • Add configurable write cadence.
  • Allow at most one external memory provider at a time.
  • Evaluate Honcho-style user modeling as optional later.
  • Evaluate local fact-store ideas before adding external dependency.

Memory Categories

  • owner facts
  • preferences
  • people/relationships
  • projects
  • routines
  • environment/tool quirks
  • character reflections

Write Cadence Options

  • immediate/manual
  • async after turn
  • session-end
  • every N turns

Module Targets

  • backend/agent/g_agent/memory/manager.py
  • backend/agent/g_agent/memory/local_store.py
  • backend/agent/g_agent/memory/types.py
  • backend/agent/g_agent/context/
  • backend/agent/tests/test_memory_manager.py
  • backend/agent/tests/test_memory_context_fencing.py

Acceptance Criteria

  • [x] Memory recall is fetched before prompt assembly through MemoryManager.
  • [x] Memory is placed under the runtime metadata section with provider fencing.
  • [x] Owner can update facts through current memory tools.
  • [x] Memory blocks use provider-level fencing.
  • [ ] Memory writes can be manual or async through a manager.
  • [x] Only one external provider can be active at a time.

References

  • hermes-agent-ref/agent/memory_manager.py
  • hermes-agent-ref/plugins/memory/honcho/README.md
  • hermes-agent-ref/plugins/memory/holographic/README.md

Agent Handoff

Current G-Agent State

  • agent/memory.py is markdown-backed and already useful.
  • MemoryStore creates and reads core files: MEMORY.md, PROFILE.md, RELATIONSHIPS.md, PROJECTS.md, FACTS.md, LESSONS.md, SUMMARIES.md, INBOX.md, and daily notes.
  • ContextBuilder calls MemoryManager.prefetch_all(query=...).
  • Tools remember, recall, and update_profile are registered from agent/tools/integrations.py.
  • Metrics can record memory recall events, but write cadence is not fully wired through the manager.

Implementation Strategy

Wrap the existing MemoryStore as the built-in provider. Do not rewrite memory storage in the first step.

Recommended shape:

  • memory/provider.py: provider interface.
  • memory/builtin.py: adapter around current MemoryStore.
  • memory/manager.py: provider orchestration.
  • memory/context.py: context fencing helpers.

Implementation Slices

  1. Add write cadence config and hook it into post-turn lifecycle.
  2. Route legacy memory tools through MemoryManager without changing command UX.
  3. Add memory feedback/update/remove actions through the manager.
  4. Add manager-level recall metrics.
  5. Add optional external provider config after the local provider is stable.

Tests

  • test_memory_manager.py
  • builtin provider registered
  • second external rejected
  • provider failure does not block builtin
  • tool schema routing works
  • test_memory_context_fencing.py
  • recalled memory is fenced
  • malicious fence tags are stripped
  • context builder includes memory in stable place.

Guardrails

  • Do not delete markdown memory files.
  • Do not add Honcho or external memory dependency in this milestone.
  • Do not auto-write memory without owner review; that belongs to v0.8.

First PR Boundary

MemoryProvider interface + BuiltinMemoryProvider adapter + MemoryManager prefetch integration in ContextBuilder. Shipped with provider registration/order/failure isolation/fenced output tests. Production-grade Hermes parity not proven; write cadence and external provider config remain.