feat(memory): Add three-layer memory system with decision routing#113
Open
AmariahAK wants to merge 1 commit into
Open
feat(memory): Add three-layer memory system with decision routing#113AmariahAK wants to merge 1 commit into
AmariahAK wants to merge 1 commit into
Conversation
Implement CORE (immutable rules), LEARNED (confidence-gated cross-session patterns), and EPHEMERAL (session-scoped, auto-cleared) memory layers with corresponding tools. Add decision routing rules to system prompt for simple/complex/conflict task routing. - New: MemoryEntry + MemoryStore Pydantic models (schema.py) - New: MemoryManager managing three layers with confidence threshold gating - New: CoreMemoryTool, LearnedMemoryTool, EphemeralMemoryTool (all extend Tool) - New: MemoryConfig in config system with YAML parsing - New: 19 comprehensive tests covering all layers and edge cases - Updated: system_prompt.md with Memory System + Decision Routing sections - Updated: cli.py registers memory tools, resets ephemeral on session end Co-authored-by: atlarix-agent <agent@atlarix.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description
i. What was the issue
Mini-Agent had a flat, single-layer memory system (
SessionNoteTool+RecallNoteToolwith a simple JSON store) and no structured decision routing. This limited the agent's ability to:Issue #110 proposed a HeartFlow-inspired three-layer memory architecture and decision routing rules.
ii. Where was the issue
mini_agent/tools/note_tool.pyMemoryConfigwithenabled,core_memory_path,learned_confidence_thresholdiii. How did you fix it
New module
mini_agent/memory/— 5 files, all following existing architecture:schema.py:MemoryEntry(Pydantic, confidence 0.0-1.0) +MemoryStore(JSON persistence, followsSessionNoteToolpattern)manager.py:MemoryManager— CORE (read-only JSON), LEARNED (confidence-gated writes ≥0.7 threshold), EPHEMERAL (in-memory,reset()on session end)tools.py:CoreMemoryTool,LearnedMemoryTool,EphemeralMemoryTool— all extend the existingToolbase class withname/description/parameters/execute → ToolResultConfig:
MemoryConfigmodel added toToolsConfig, parsed infrom_yaml()following theMCPConfigpattern.System prompt: New
## Memory Systemsection (3 layers documented) +## Decision Routingsection (simple/complex/conflict routing with 6-step think→plan→execute→verify→reflect→learn cycle).CLI: Memory tools registered in
initialize_base_tools()with the existing green-checkmark pattern. EPHEMERAL reset called at session start and end.iv. Why did you choose that method over others
Toolbase — zero changes to theAgent.run()loop. Tools are registered by name intoself.toolsdict, dispatched by the LLM automatically. No new infrastructure needed.SessionNoteToolpattern (load/save viaMemoryStore.load_from_file/save_to_file). No new dependencies.MCPConfignested-model pattern with defaults, parsed infrom_yaml(). Users can disable memory or tune thresholds without touching code.MemoryManager.record_learned()returns(accepted: bool, reason: str), keeping the tool layer thin and the gating logic centralized.v. How to test it locally