Files
hermes-agent/plugins/memory
Alexander Whitestone 29ff50c63d
Some checks failed
Docker Build and Publish / build-and-push (pull_request) Has been skipped
Nix / nix (ubuntu-latest) (pull_request) Failing after 3s
Supply Chain Audit / Scan PR for supply chain risks (pull_request) Failing after 1m6s
Tests / e2e (pull_request) Successful in 2m0s
Tests / test (pull_request) Failing after 33m14s
Nix / nix (macos-latest) (pull_request) Has been cancelled
feat: Long Context vs RAG Decision Framework (research backlog #4.3)
Implements adaptive retrieval strategy that adjusts prefetch behavior
based on context pressure. With models at 128K-1M context windows,
always prefetching RAG is wasteful when context is empty and
insufficient when context is full.

Core changes:
- agent/context_strategy.py: Strategy module with ContextBudget,
  compute_prefetch_params(), should_prefetch() - STUFF/HYBRID/SELECTIVE
  tiers based on context pressure (30%/70% thresholds)
- agent/memory_manager.py: set_context_budget() method + adaptive
  prefetch in prefetch_all() with provider fallback for non-supporting
- plugins/memory/holographic: Accept limit/min_trust kwargs in prefetch()
- run_agent.py: Wire context_compressor state to memory_manager before
  prefetch_all() call
- tools/context_strategy.py: Agent-facing tool with task classification
  (crisis/factual/creative/analysis) and decision engine with 6 rules

Research basis:
- Self-RAG (Asai et al., 2023) - arxiv 2310.11511
- Long Context vs RAG Decision Framework (Timmy Foundation #4.3)
- FrugalGPT - arxiv 2305.05176

Tests: 19 new tests pass. Full context strategy, prefetch params,
should_prefetch decision logic, and strategy report generation.

Impact: Ratio 4.0 (Impact 4, Effort 1). Eliminates over-retrieval on
large-context models and prevents under-retrieval when context is tight.
Crisis intervention tasks always get HYBRID minimum for safety.
2026-04-12 04:58:13 -04:00
..