Skip to content

feat: Context tracker for multi-step retrieval (Neural Mesh RAG Phase 1) #2005

@mrveiss

Description

@mrveiss

Context

Part of Neural Mesh RAG (#1994), Phase 1, Task 1.5.

Problem

No mechanism to prevent redundant chunk reads across multi-step retrieval. When agentic RAG (Phase 5) executes multiple retrieval steps, the same chunks get re-read and re-ranked, wasting tokens and latency.

Implementation

  • Create ContextTracker class with per-query-session scope
  • filter_unseen(chunks) — return only chunks not seen in this session
  • record(chunk_ids, tokens) — mark chunks as seen, track token budget
  • summary() — return session stats for logging
  • Token budget tracking with tokens_remaining property

Files

  • Create: autobot-backend/knowledge/search_components/context_tracker.py
  • Test: autobot-backend/knowledge/search_components/context_tracker_test.py

Plan Reference

docs/plans/2026-03-22-neural-mesh-rag-implementation.md Task 1.5

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions