Skip to content

Commit 2bdbcce

Browse files
xni-ievan-ak
andauthored
feat: Add salience-aware memory with reinforcement tracking (#186) (#206)
Co-authored-by: Wu <evan299792458@outlook.com>
1 parent 5213571 commit 2bdbcce

23 files changed

Lines changed: 2928 additions & 17 deletions

docs/HACKATHON_ISSUE_DRAFT.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# GitHub Issue Draft: Memory Types + Tool Memory
2+
3+
## Title
4+
`[2026NewYearChallenge] Specialized Memory Types with Tool Learning`
5+
6+
---
7+
8+
## Description
9+
10+
### What will this task implement?
11+
12+
This PR enhances MemU's memory type system to support specialized memory structures with type-specific metadata and introduces Tool Memory for agent self-improvement.
13+
14+
**Current State:** MemU has a `memory_type` field with 5 types (profile, event, knowledge, behavior, skill) and uses different LLM prompts to extract each type. However, after extraction, all memories share the same storage schema - just `summary` and `embedding`. There's no type-specific metadata, no type-aware retrieval, and no way for agents to learn from their tool usage.
15+
16+
**Enhancement:** Extend the memory system to support:
17+
- Type-specific metadata fields (e.g., `when_to_use` for smarter retrieval)
18+
- Tool Memory type for tracking tool execution history
19+
- Tool usage statistics for agent self-improvement
20+
- Type-aware retrieval filtering
21+
22+
**Key Benefits:**
23+
- Agents can learn from their own tool usage patterns
24+
- Smarter retrieval based on memory context
25+
- Foundation for agents that improve over time
26+
- Better alignment with agentic application needs
27+
28+
---
29+
30+
## Requirements
31+
32+
- [x] Type-specific metadata schema with `when_to_use` field
33+
- [x] Tool Memory implementation with execution tracking
34+
- [x] Tool statistics (success_rate, avg_time_cost, avg_score)
35+
- [ ] Type-aware retrieval filtering
36+
- [x] Tests for Tool Memory CRUD and statistics
37+
- [ ] Documentation and usage examples
38+
39+
---
40+
41+
## Review Criteria
42+
43+
- Correctness: All tests pass, no regressions
44+
- Quality: Clean code, follows existing patterns
45+
- DX: Clear documentation and examples
46+
- Impact: Enables agent self-improvement use cases
47+
48+
---
49+
50+
## Implementation Summary
51+
52+
### Files Modified:
53+
1. `src/memu/database/models.py` - Added `ToolCallResult` model, extended `MemoryItem` with `when_to_use`, `metadata`, `tool_calls` fields
54+
2. `src/memu/database/repositories/memory_item.py` - Updated interface with new fields
55+
3. `src/memu/database/inmemory/repositories/memory_item_repo.py` - Updated implementation
56+
4. `src/memu/database/postgres/repositories/memory_item_repo.py` - Updated implementation
57+
5. `src/memu/database/postgres/models.py` - Added JSON columns for new fields
58+
6. `src/memu/prompts/memory_type/__init__.py` - Added tool type
59+
7. `src/memu/prompts/memory_type/tool.py` - New prompt for tool memory extraction
60+
61+
### Files Added:
62+
1. `tests/test_tool_memory.py` - 14 unit tests for Tool Memory feature
63+
64+
---
65+
66+
## Notes
67+
68+
This builds on MemU's existing memory type foundation while adding the specialized structures needed for agentic applications. The Tool Memory feature is particularly valuable for agents that need to learn which tools work best in different situations.

0 commit comments

Comments
 (0)