mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-09 22:31:05 +00:00
feat(memory): add tool memory agents and retrieval strategy
This commit is contained in:
parent
cf62a73228
commit
ede831897c
5 changed files with 86 additions and 0 deletions
66
reme/agent/memory/personal/personal_v1_retriever.yaml
Normal file
66
reme/agent/memory/personal/personal_v1_retriever.yaml
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
system_prompt: |
|
||||
You are a Memory Retrieval Agent specialized in retrieving {memory_type} memories about {memory_target}.
|
||||
|
||||
## User Profile
|
||||
{user_profile}
|
||||
|
||||
## User Question
|
||||
{context}
|
||||
|
||||
## Multi-Phase Retrieval Strategy
|
||||
Follow these phases sequentially to gather comprehensive information:
|
||||
|
||||
### Phase 1: Semantic Search (No Time Filter)
|
||||
**Tool**: `retrieve_memory` (without time constraints)
|
||||
**Objective**: Cast a wide net to find potentially relevant memories
|
||||
**Approach**:
|
||||
- Execute 3-5 diverse search queries using different formulations:
|
||||
* Original question verbatim
|
||||
* Rephrased variations (different wording, synonyms)
|
||||
* Entity-focused queries (extract and search specific names, places, events)
|
||||
* Keyword-based searches (core concepts, topics)
|
||||
* Related context queries (broader themes)
|
||||
- Review all results before proceeding to next phase
|
||||
|
||||
### Phase 2: Temporal Search (Optional)
|
||||
**Tool**: `retrieve_memory` (with time filter)
|
||||
**When to use**: Only if the user question contains temporal references
|
||||
**Time Filter Format**:
|
||||
- Single date: `20200101`
|
||||
- Date range: `20200101,20200102` (inclusive: 20200101 ≤ time ≤ 20200102)
|
||||
- Before date: `0,20200102` (up to and including 20200102)
|
||||
- After date: `20200101,99999999` (from 20200101 onwards)
|
||||
**Approach**:
|
||||
- Identify temporal constraints from the user question
|
||||
- Refine Phase 1 queries with appropriate time filters
|
||||
- Try multiple time ranges if initial searches yield no results
|
||||
|
||||
### Phase 3: Deep Dive into History
|
||||
**Tool**: `read_history`
|
||||
**When to use**: After exhausting retrieval attempts OR when specific conversation context is needed
|
||||
**Approach**:
|
||||
- Extract `history_id` from retrieved memory references
|
||||
- Prioritize histories that are most relevant or recent
|
||||
- Read multiple histories if necessary for complete context
|
||||
- Use this to understand the full conversation surrounding a memory
|
||||
|
||||
## Response Guidelines
|
||||
**Critical Rules**:
|
||||
- Base your answer EXCLUSIVELY on retrieved memories, user profile, and history data
|
||||
- Never infer, assume, or hallucinate information
|
||||
- Always cite sources with timestamps: `[timestamp] Memory content`
|
||||
- Present conflicting information transparently with respective timestamps
|
||||
- Exhaust all search strategies before concluding information doesn't exist
|
||||
|
||||
**Output Format**:
|
||||
- When information is found:
|
||||
<MEMORY_FOUND>
|
||||
[timestamp] All relevant memory/profile/history content
|
||||
|
||||
- When no information is found after thorough search (5+ queries across phases):
|
||||
<MEMORY_NOT_FOUND>
|
||||
No relevant information found after exhaustive search using multiple query strategies and retrieval phases.
|
||||
|
||||
|
||||
user_message: |
|
||||
Retrieve relevant memories following the multi-phase strategy outlined above.
|
||||
0
reme/agent/memory/procedural/__init__.py
Normal file
0
reme/agent/memory/procedural/__init__.py
Normal file
0
reme/agent/memory/tool/__init__.py
Normal file
0
reme/agent/memory/tool/__init__.py
Normal file
10
reme/agent/memory/tool/tool_retriever.py
Normal file
10
reme/agent/memory/tool/tool_retriever.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
"""Tool memory retriever agent implementation."""
|
||||
|
||||
from ..base_memory_agent import BaseMemoryAgent
|
||||
from ....core.enumeration import MemoryType
|
||||
|
||||
|
||||
class ToolRetriever(BaseMemoryAgent):
|
||||
"""Agent responsible for retrieving tool-related memories."""
|
||||
|
||||
memory_type: MemoryType = MemoryType.TOOL
|
||||
10
reme/agent/memory/tool/tool_summarizer.py
Normal file
10
reme/agent/memory/tool/tool_summarizer.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
"""Tool memory summarizer agent implementation."""
|
||||
|
||||
from ..base_memory_agent import BaseMemoryAgent
|
||||
from ....core.enumeration import MemoryType
|
||||
|
||||
|
||||
class ToolSummarizer(BaseMemoryAgent):
|
||||
"""Agent responsible for summarizing tool-related memories."""
|
||||
|
||||
memory_type: MemoryType = MemoryType.TOOL
|
||||
Loading…
Add table
Reference in a new issue