-
Notifications
You must be signed in to change notification settings - Fork 93
MemoryMixin: 5 memory tools + 3 lifecycle hooks for any agent #543
Copy link
Copy link
Open
Labels
agentconsumerBlocks consumer adoption — must ship for the v0.20.0 consumer launch windowBlocks consumer adoption — must ship for the v0.20.0 consumer launch windowdomain:agent-coreFramework, tools, registry, memory, skills, orchestrationFramework, tools, registry, memory, skills, orchestrationenhancementNew feature or requestNew feature or requestp0high priorityhigh prioritysdkSDK/framework changesSDK/framework changestrack:consumer-appHermes-competitor consumer product — mobile-first, voice + messaging + memory + skillsHermes-competitor consumer product — mobile-first, voice + messaging + memory + skills
Metadata
Metadata
Assignees
Labels
agentconsumerBlocks consumer adoption — must ship for the v0.20.0 consumer launch windowBlocks consumer adoption — must ship for the v0.20.0 consumer launch windowdomain:agent-coreFramework, tools, registry, memory, skills, orchestrationFramework, tools, registry, memory, skills, orchestrationenhancementNew feature or requestNew feature or requestp0high priorityhigh prioritysdkSDK/framework changesSDK/framework changestrack:consumer-appHermes-competitor consumer product — mobile-first, voice + messaging + memory + skillsHermes-competitor consumer product — mobile-first, voice + messaging + memory + skills
Summary
Build the agent integration layer for memory. A mixin that any Agent subclass can opt into, providing persistent memory through 3 automatic hooks and 5 LLM-facing tools.
Spec:
docs/spec/agent-memory-architecture.md→ "File 2: memory.py"Depends on: #542 (MemoryStore)
Supersedes gaia6: Replaces 8-tool MemoryMixin with 5-tool CRUD design. Adds auto tool logging, error learning, temporal awareness, context scoping.
3 Lifecycle Hooks
Hook 1: System Prompt Injection
get_memory_system_prompt()— injects current time, preferences, facts, error patterns, upcoming/overdue items. Filters by active context, excludes sensitive items.Critical: Invalidates
_system_prompt_cacheat start of eachprocess_query()so memory context is always fresh.Hook 2: Tool Execution Wrapper
_execute_tool()override — auto-logs every non-memory tool call to tool_history. Auto-stores novel errors asknowledge(category='error').Hook 3: Post-Query Storage
_after_process_query()— stores conversation turns (tagged with context), runs heuristic extraction (regex patterns for preferences/facts).5 LLM Tools
rememberrecallupdate_memoryforgetsearch_past_conversationsClass Interface
Agent Base Changes (agent.py)
get_memory_system_promptcheck to_get_mixin_prompts()(4 lines)_after_process_queryhook at end ofprocess_query()(2 lines)Acceptance Criteria