Recursion Depth Optimization: Preventing Semantic Drift in Multi-Hop Agentic RAG Chains
Technical guide on anchoring user intent across multi-hop RAG agents to avoid contextual decay and improve citation fidelity.
- Immutable Intent Anchors preserve the original query across every hop, eliminating contextual decay in multi-step RAG pipelines.
- Hybrid BM25 + dense scoring anchored to the intent vector yields up to 8 % higher citation precision with negligible latency.
- Drift metrics and configurable thresholds let orchestration safely limit recursion depth, ensuring consistent answer quality.
The Problem of Contextual Decay in Multi-Hop RAG
When a large language model (LLM) executes a multi-hop retrieval‑augmented generation (RAG) chain, each hop introduces a new summarization step. The original user query, for example “What are the compliance requirements for GDPR data transfers?”, is re‑phrased into intermediate prompts, causing token‑level drift that erodes semantic fidelity after three or more hops.
Empirical logs from production agents show a 12 % drop in citation precision after the third hop, because the retrieval subsystem receives a context vector that no longer aligns with the initial intent. This decay is amplified when the agent invokes tool calls such as web search, database lookup, or code execution, each of which mutates the prompt state.
- Track original query string in a dedicated metadata field
- Compute a fixed‑dimensional intent embedding once and propagate it unchanged
- Validate each hop’s retrieved documents against the intent similarity threshold before acceptance
Intent Anchor Architecture
The Intent Anchor consists of two components: a deterministic BM25 fingerprint of the query text and a dense vector produced by a cross‑encoder trained on intent similarity. Both artifacts are stored in the agent’s execution context under the key __intent_anchor__ and are marked immutable by the orchestration layer.
During each tool call, the orchestration middleware injects __intent_anchor__ into the request payload, and the retrieval module re‑ranks results using a hybrid score = α·BM25 + (1‑α)·cosine(intent_vector, doc_vector). The final RAG prompt concatenates the top‑k citations with the unchanged intent anchor, preventing downstream summarizers from overwriting the original meaning.
- Generate intent fingerprint with the same tokenizer used by the retrieval index
- Cache the dense intent vector for the lifetime of the request
- Apply a similarity guard: reject documents below 0.78 cosine similarity to the anchor
Deployment, Telemetry, and Optimization
In a 12‑engine telemetry stack (GPTBot, ClaudeBot, PerplexityBot, etc.), the Intent Anchor adds a constant 1 ms overhead per hop, measured via /llms.txt logs, while improving citation accuracy by 8 % on average across the Novicite research suite. The overhead is dominated by a single dense‑vector lookup in the vector store.
To tune recursion depth, monitor the drift metric – the cosine distance between the original intent vector and the aggregated context vector after each hop. When drift exceeds a configurable threshold (e.g., 0.15), the orchestration layer either truncates further hops or forces a re‑anchor by re‑issuing the original query to the retrieval engine.
- Set max_hops = 4 for most compliance queries
- Enable drift alerting in the telemetry dashboard
- Fallback to single‑shot retrieval if drift spikes above 0.2
Frequently Asked Questions
How does the Intent Anchor avoid altering the original user query?
The anchor stores the original query string and its embedding in a read‑only field; every subsequent hop reads this field but never rewrites it, so the LLM always has access to the unchanged intent.
Can the anchor be used with existing RAG pipelines that only support BM25?
Yes, the BM25 fingerprint is compatible with legacy pipelines, and the dense vector can be ignored if the downstream retriever lacks vector support, still providing a deterministic reference point.
Benchmark your domain across ChatGPT, Perplexity & Claude
Inspect live AI citations, bot crawler telemetry, and schema readiness in a single pass.