Skip to content

feat: agent memory system design#226

Draft
esafwan wants to merge 52 commits into
developfrom
feature/agent-memory-system-design
Draft

feat: agent memory system design#226
esafwan wants to merge 52 commits into
developfrom
feature/agent-memory-system-design

Conversation

@esafwan
Copy link
Copy Markdown
Contributor

@esafwan esafwan commented Mar 28, 2026

No description provided.

esafwan added 30 commits March 28, 2026 11:04
- PRD: Programmable Memory & Learning Layer
- DocType designs: Memory Record, Policy, Profile
- Tech specs: Capture/Retrieval, Storage Architecture
- Profiles: Travel Planning, Programming, Documentation
- Implementation plan and project tracking
…n status

- Updated progress to ~25% (design and frontend types complete)
- Added frontend developer to agent assignments
- Documented new frontend deliverables (memory.types.ts, memoryApi.ts)
- Updated milestone statuses for completed profile designs
- Added Memory Record Tag to completed milestones
- Updated communication log with recent agent completions
- Comprehensive summary of completed work (~25%)
- Detailed breakdown of pending tasks by phase
- Agent assignment summary
- Risk mitigation recommendations
- File inventory for easy navigation
Backend:
- Memory Record, Policy, Profile, Record Tag DocTypes
- Capture modes, triggers, processor
- Storage layer with indexing
- Retrieval modes, search, injection
- Agent/Conversation/Run integrations

Frontend:
- MemoryPanel component
- Memory hooks

All components implemented per PRD spec.
- Add memory_write_tool.py with memory_write function
- Supports all memory types (profile, preference, fact, etc.)
- Auto-resolves agent/conversation from context
- Validates scope_type, memory_type, visibility
- Returns structured response with success/error details

Task: E4 (Memory Write Tool)
Dependencies: A1 (COMPLETE)
- Add RuleOnlyCaptureMode class with 7 rule types
- Support static, context, regex, jsonpath, tool, computed, jinja rules
- Full validation and error handling
- Comprehensive documentation and examples
- Default profiles for Memory Profile
- Storage service implementation
- Memory record tests
- Tool template updates
- Add MemoryRetrievalService class with unified retrieval interface
- Support for all retrieval modes: inject, tool_only, hybrid
- RetrievalContext dataclass for scoping
- RetrievalResult dataclass for standardized responses
- Token budgeting for prompt injection
- Retrieval stats tracking (last_retrieved_at, retrieval_count)
- API endpoints: retrieve_memories, get_memory_by_id

Task: E1 (Memory Retrieval Service)
Dependencies: A1, D1 (COMPLETE)
esafwan added 22 commits March 28, 2026 11:17
- Add memory_search function with full-text and filter support
- Add convenience tools: memory_get_recent, memory_get_by_type, memory_get_by_scope
- Auto-resolves agent/conversation from frappe flags/context
- Validates memory_type, scope_type parameters
- Returns structured response with pagination info
- All functions whitelisted for agent tool execution

Task: E3 (Memory Search Tool)
Dependencies: E1 (COMPLETE)
- Add InPromptCaptureMode with zero-latency capture
- Build memory instruction prompts for agent integration
- Validate and normalize memory records from responses
- Include InPromptCaptureResponseBuilder helper class
- Mark F1 (5 opinionated profiles) as complete
- Mark F2 (Memory Explorer) as complete
- Mark F3 (Agent Memory Tab) as complete
- Mark F4 (Conversation Inspector) as complete
- Add MemoryPromptInjector class with multiple format styles (markdown, json, xml)
- InjectionConfig dataclass for customization
- Support for different injection positions (beginning, after_instructions, end)
- Token budgeting and memory grouping by type
- Convenience functions: build_memory_context, inject_memory_into_prompt
- API endpoint: get_injection_preview for debugging
- Package __init__.py with all exports

Task: E2 (Prompt Injection)
Dependencies: E1 (COMPLETE)
- Add get_memory_tool_definitions() method with full tool schemas
- Add register_memory_tools() method for dynamic tool registration
- Tool definitions for memory_search and memory_write
- Compatible with Agent Tool Function DocType format

Related: E2, E3, E4 (COMPLETE)
- Add MemoryAgentCaptureMode with dedicated agent support
- Support sync and async execution timing
- Configurable context passing (full history or summary)
- Background job processing with retry logic
- Include process_memory_agent_job handler
- Add PostRunAsyncCaptureMode with background job support
- Context snapshot and storage for reliable processing
- Retry mechanism with exponential backoff
- Fallback capture modes on failure
- Background job handlers with persistence and indexing

feat(capture): Add capture service orchestrator

- Central CaptureService for all capture operations
- Policy-based configuration loading
- Unified capture interface with trigger evaluation
- Convenience functions for direct use
- Complete technical documentation for HUF Agent Memory System
- Covers all 5 capture modes, 9 triggers, 3 retrieval modes
- Documents storage backends (FTS5, sqlite-vec, hybrid)
- Includes API reference and configuration examples
- File structure and integration guide
Add structured skills for HUF Agent Memory System:
- capture/SKILL.md: 5 capture modes with examples
- retrieval/SKILL.md: 3 retrieval modes and prompt injection
- profiles/SKILL.md: 5 built-in profiles and custom creation
- storage/SKILL.md: Backends (FTS, vector, hybrid) and storage API
- tools/SKILL.md: Memory tools for agents (search, write, etc.)
- README.md: Skill index and quick reference

Each skill includes:
- Configuration examples
- Code snippets
- Best practices
- API reference
Create detailed task specifications for:
- backend-doctypes: Frappe DocType infrastructure
- capture-pipeline: All capture modes and triggers
- storage-indexing: FTS, vector, and storage backends
- retrieval-system: Prompt injection and search tools
- ui-integration: Agent Memory tab and Memory Explorer

Update PROJECT_TRACKING.md with dispatched tasks.
- Discovered implementation is ~85% complete (not 25%)
- Documented 14,254 lines of Python across all phases
- Catalogued all completed components
- Identified remaining work: 3 profiles + UI components + integration testing
- Updated all phase statuses to reflect actual progress
- Add MemoryAgentIntegration class for injection and capture
- Add runner_hooks.py with pre_run_hook and post_run_hook
- Create AGENT_INTEGRATION_PATCH.py guide for agent_integration.py
- Add comprehensive INTEGRATION_README.md documentation
- Create test_memory_integration.py with end-to-end tests
- Update memory/__init__.py to export integration functions
- Update IMPLEMENTATION_STATUS_REPORT.md with new progress

The integration provides:
- Pre-execution memory injection into agent prompts
- Post-execution memory capture from conversations
- Agent Run observability fields for memory metrics
- Comprehensive error handling and fallbacks
…ntation

- Create setup.py with after_install() and after_migrate() hooks
- Seed 7 default Memory Profiles (Programming, General, Travel, Documentation,
  Science, Language Learning, CRM) with schemas and prompts
- Seed 3 default Memory Policies (Conservative, Aggressive, Rules-Only)
- Add comprehensive help_text to all Memory DocType fields
- Update MemoryTab.tsx and MemoryPolicyForm.tsx with inline help/tooltips
- Create docs/memory/ directory with 8 documentation files:
  - overview.md: Mental model and architecture
  - getting-started.md: Quick start guide
  - profiles.md: Profile documentation with examples
  - capture-modes.md: Capture timing and strategies
  - retrieval.md: Search, ranking, and injection
  - api-reference.md: Python and frontend API reference
  - best-practices.md: Production recommendations
  - README.md: Documentation index
- Update AGENTS.md with Memory System architecture overview
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant