Skip to content

feat: implement tool-based memory retrieval injection strategy #207

@Aureliolo

Description

@Aureliolo

Summary

Memory injection Strategy 2: agent has recall_memory / search_memory tools it calls on-demand during execution. Currently only Strategy 1 (context injection) is implemented.

Design Spec Reference

  • §7.7 Memory Injection Strategies — Strategy 2: Tool-Based Retrieval

Scope

  • recall_memory and search_memory tool implementations
  • MemoryInjectionStrategy protocol compliance
  • get_tool_definitions() returns tool schemas for LLM
  • Integration with ToolRegistry

Research Context

Four independent sources provide implementation blueprints:

1. Memex (arXiv:2603.04257) — CompressExperience/ReadExperience tool pair:

  • CompressExperience: archives current context into KV store, replaces working context with structured summary + index table
  • ReadExperience: dereferences an index to reinject archived block (deterministic lookup, not semantic search)
  • Index-description pairs as compact context representation
  • Results: 24.2%→85.6% success, 43% context reduction

2. NeMo Retriever (NVIDIA) — Tool triad blueprint:

  • recall_memory(query, top_k) + search_memory(query, keyword_weight) + compact_context()
  • Agent decides when to retrieve and when to compress
  • 760k tokens/query cost warning — only for complex retrievals

3. Agentic RAG (TDS) — Three agentic patterns:

  • Query rewriting: agent reformulates queries for better retrieval
  • Sufficiency checking: agent evaluates results and iterates if insufficient
  • Dynamic weighting: tool accepts keyword_weight param to shift BM25-vs-vector per query

4. LangChain Context Compression/compact manual trigger:

  • Agent-triggered compaction at clean task boundaries
  • Conservative tuning (agents rarely trigger, but choose good moments)

See research/agentic-retrieval-patterns.md and research/memex-indexed-experience-memory.md in project memory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    prio:mediumShould do, but not blockingscope:medium1-3 days of workspec:memoryDESIGN_SPEC Section 7 - Memory & Persistencespec:toolsDESIGN_SPEC Section 11 - Tool & Capability Systemtype:featureNew feature implementationv0.6Minor version v0.6v0.6.1Patch release v0.6.1

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions