Idea: Semantic memory search & retrieval via MemoryIndexMiddleware #6032
Replies: 1 comment
|
This is an interesting direction, especially for long-running agents where manually navigating memory paths can become difficult. One thing I’d be curious about is how the index would stay consistent when memories are updated or deleted. Would MemoryIndexMiddleware update the embedding index synchronously on each write, or would indexing happen asynchronously? It might also be useful to have a fallback to the existing path-based lookup when semantic search returns low-confidence results, rather than making semantic retrieval the only path. The namespace isolation in the proposed API also looks important, especially for multi-user deployments. I’d definitely be interested in seeing a small benchmark comparing exact/path retrieval vs semantic retrieval for long-running agents. |
Uh oh!
There was an error while loading. Please reload this page.
Idea: Semantic memory search & retrieval via
MemoryIndexMiddlewareSummary
Today,
StoreBackendenables persistent cross-session memory in DeepAgents, but discovery is restricted to exact path lookups (read_file,ls) or literal substring matching (grep). As agents accumulate notes, preferences, and long-horizon facts across dozens of sessions, string-matching degrades rapidly.We propose adding a
MemoryIndexMiddlewarethat seamlessly hooks into persistent store operations (e.g./memories/*) to maintain an embedding-backed semantic index, exposing a zero-overheadsearch_memorytool to the agent.The Problem
grep, which fails when phrasing differs (e.g., searching for "database configuration" when the file contains "PostgreSQL connection string").ls /memories/) and sequentially read multiple files (read_file), unnecessarily exhausting token budgets and latency.BackendProtocolrequired: Storing and searching memory are separate concerns. Introducing semantic search shouldn't require bloatingStoreBackendor alteringBackendProtocol.Proposed Solution:
MemoryIndexMiddlewareBy leveraging DeepAgents' extensible Middleware architecture, semantic indexing can be plugged in without touching core backend protocols or altering existing storage adapters:
Key Highlights:
Embeddingsmodel (OpenAIEmbeddings,HuggingFaceEmbeddings, local models via Ollama/vLLM)./memories/**in aCompositeBackendsetup), leaving workspace files untouched.create_deep_agentconfigurations.Proposed Usage & API
Agent Tool Exposed:
Why this belongs in DeepAgents
StoreBackend) and context efficiency.StoreBackend,CompositeBackend, orBackendProtocol.Next Steps
I am happy to submit a clean Draft PR implementing:
MemoryIndexMiddlewareinlibs/deepagents/deepagents/middleware/memory_index.pywrite_file/edit_fileand tool query returnsWould the maintainers be open to a PR for this? We'd love feedback on design and API ergonomics!
All reactions