feat: add memory API and optimize memory middleware

- Add memory API endpoints for retrieving memory data:
  - GET /api/memory - get current memory data
  - POST /api/memory/reload - reload from file
  - GET /api/memory/config - get memory configuration
  - GET /api/memory/status - get config and data together
- Optimize MemoryMiddleware to only use user inputs and final
  assistant responses, filtering out intermediate tool calls
- Add memory configuration example to config.example.yaml

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hetaoBackend
2026-02-03 13:41:04 +08:00
parent 18d85ab6e5
commit 7b7a7abaf2
4 changed files with 267 additions and 8 deletions

View File

@@ -278,3 +278,15 @@ summarization:
# - Custom MCP server implementations
#
# For more information, see: https://modelcontextprotocol.io
# Global memory mechanism
# Stores user context and conversation history for personalized responses
memory:
enabled: true
storage_path: .deer-flow/memory.json # Path relative to backend directory
debounce_seconds: 30 # Wait time before processing queued updates
model_name: null # Use default model
max_facts: 100 # Maximum number of facts to store
fact_confidence_threshold: 0.7 # Minimum confidence for storing facts
injection_enabled: true # Whether to inject memory into system prompt
max_injection_tokens: 2000 # Maximum tokens for memory injection