Grading Long-Context Retrieval Agents from Logs with Cluster-Level Importance Weights

Checking whether a new multi-step retrieval agent works on a long document usually means running it: the agent retrieves a passage, reads it, retrieves another, and a large language model then answers from what was gathered. At 32K to 128K tokens of context, doing this for every candidate policy and every prompt is expensive, and benchmarks such as RULER show that cheap proxies like needle-in-a-haystack tell you almost nothing. The alternative is off-policy evaluation, which estimates how a new policy would score by reweighting the logged runs of an old one. That route fails here twice over. Each retrieval step chooses among thousands of chunks, so the logged probability of any particular chunk is tiny and importance weights explode. Several steps are chained, so those exploding weights multiply.

We propose to reweight each step by the probability of the group of chunks chosen rather than the chunk itself, and to let a learned value model correct for which chunk inside the group was taken. This extends conjunct-effect modeling from one-step recommendation to multi-hop retrieval. It keeps a clean unbiasedness guarantee: the value model only needs to rank chunks correctly relative to their neighbours in the same group. The result is an estimator that can rank long-context retrieval policies from outcome-only logs, with no chunk-level annotations and no new rollouts.

Core Claim

Cluster-level importance weighting survives the move from one step to many, provided the reward correction is replaced by a correction to the action value. The action value is the expected final reward from taking a chunk and then following the target policy.

Consider a logged trajectory of retrieval steps $t=0,\dots,T-1$. Let $s_t$ be the query plus the chunks retrieved so far, and $a_t$ the chunk retrieved. A fixed map $c(\cdot)$ assigns each chunk of the current document to one of $K$ clusters. Define the per-step cluster ratio $w_t=\pi_e(c(a_t)\mid s_t)/\pi_b(c(a_t)\mid s_t)$, where $\pi_e$ is the target policy, $\pi_b$ the logging policy, and $\pi(c\mid s)$ the total probability a policy puts on chunks in cluster $c$. Let $W_t=\prod_{k\le t}w_k$, with $W_{-1}=1$, and let $r_t$ be the reward at step $t$ (nonzero only at the final answer). The estimator is

$$\hat V=\frac{1}{n}\sum_{i=1}^{n}\sum_{t=0}^{T-1}\Big[W_t\big(r_t-\hat Q(s_t,a_t)\big)+W_{t-1}\,\mathbb{E}_{a\sim\pi_e(\cdot\mid s_t)}\hat Q(s_t,a)\Big],$$

where $\hat Q$ is a learned estimate of the target policy's action value $Q^{\pi_e}$.

The claim to prove is that $\hat V$ is unbiased whenever two conditions hold. The first is that every cluster the target policy uses has positive logging probability. The second is that $Q^{\pi_e}(s,a)-\hat Q(s,a)$ depends on $(s,c(a))$ only, which we call per-step local correctness. The one-step argument of Off-Policy Evaluation for Large Action Spaces via Conjunct Effect Modeling goes through unchanged at each step. Under the logging policy's within-cluster choice, the residual's expectation is a per-cluster constant, and reweighting clusters turns that constant into its target-policy expectation. Induction backward over steps does the rest. The next-step term needs no separate correction, because the future consequence of picking one chunk over its cluster-mates is already inside $Q^{\pi_e}(s_t,a_t)$.

The variance now compounds over ratios of cluster probabilities, which are orders of magnitude larger than chunk probabilities, instead of over ratios of chunk probabilities. When both policies spread probability within a cluster the same way, $w_t$ equals the exact action ratio and no value model is needed at all.

Relation to Prior Work

Three single-step estimators supply the mechanism, and all three stop at one step:

  • MIPS (Off-Policy Evaluation for Large Action Spaces via Embeddings) reweights on action embeddings and assumes the embedding fully explains the reward.
  • OffCEM reweights on clusters and repairs within-cluster effects by regression, with the local-correctness guarantee.
  • POTEC turns the same split into a two-stage policy learner.

We reuse OffCEM's decomposition but move the regression target from immediate reward to $Q^{\pi_e}$, which is what makes chaining possible.

Two works constrain the design:

  • Clustering Context in Off-Policy Evaluation shows a V-shaped error curve in the number of clusters. We therefore treat $K$ as a quantity to select from data rather than fix, and we measure whether the optimal $K$ shifts with the number of hops.
  • Using Options for Long-Horizon Off-Policy Evaluation groups actions over time, so that shared sub-policies give weight exactly 1. We group actions within a step, over the space of chunks, and do not require predefined options or small action sets.

On the long-context side, two works motivate the problem:

  • LongRLVR shows that outcome-only rewards give almost no learning signal for which chunks to ground on, and fixes this online with chunk labels from a teacher model.
  • Q-RAG trains a multi-step retrieval agent with temporal-difference value learning in chunk-embedding space, also online.

Neither can score a new policy from logs. We borrow Q-RAG's value architecture to fit $\hat Q$. We deliberately use only logged final-answer outcomes, which is the setting LongRLVR cannot handle.

Prompt Optimization with Logged Bandit Data is the closest attempt to marginalized off-policy estimation for language models. It kernel-smooths over sentence embeddings, but for a single short output, and it leaves a doubly robust form open. Our estimator is doubly robust by construction, for hard clusters rather than soft kernels.

Research Program

Environment. We build the evaluation environment on the griver/Q-RAG codebase. An agent over a chunked long document selects one chunk per step for $T$ steps (2 to 5, matching the hop count of the task). A frozen language model then answers, and the reward is answer correctness.

Logging and target policies. Logging policies are softmax retrievers with known probabilities over all chunks: Q-RAG checkpoints at several temperatures, and a BM25 score passed through a softmax. Target policies are a pool of about twenty other checkpoints, temperatures and scoring rules, chosen to vary in how far they are from each logging policy.

Clusters. For each document, clusters come from K-Means on chunk embeddings, following OffCEM's use of K-Means. A second variant groups chunks by the fitted $\hat Q$ itself, which targets the known gap that no clustering is tailored to the estimator. $K$ is chosen per task by a held-out estimate of error in the spirit of the SLOPE procedure from MIPS.

Value model. $\hat Q$ is fitted by fitted-Q evaluation on the logs. Because the state includes only the query and the retrieved chunks, not the full 128K context, the value model stays tractable.

Theory. Beyond the unbiasedness result, we will derive a variance bound in terms of the per-step second moments of the cluster ratios. The aim is a quantitative prediction: the advantage over chunk-level estimators should grow with chunks per cluster (hence with context length) and compound with hop count. We will also characterize the bias when local correctness fails, as a function of within-cluster error in $\hat Q$.

Baselines

Naive reference. The average logged outcome of the logging policy, which is what a practitioner has if they do nothing. Every estimator must beat it on policy ranking, or it adds nothing.

Budget-matched online evaluation. Run each target policy live on a small random subset of prompts, with the language-model inference cost matched to what our method spends fitting $\hat Q$ and scoring. We count cost in answer-model calls and wall-clock time on the same hardware. Beating it means lower mean squared error in value, or a better policy ranking, at equal compute. This is the most practically relevant competitor.

Chunk-level sequential doubly robust estimation. The same equation with exact chunk ratios in place of cluster ratios, with and without weight clipping. We also include per-decision and weighted importance sampling. Using Options for Long-Horizon Off-Policy Evaluation reports that its INCRIS method has "one to two orders of magnitude lower MSE" than per-decision and weighted importance sampling. We include INCRIS as the strongest existing horizon-side estimator.

Direct method. The fitted-Q estimate $\mathbb{E}_{\pi_e}\hat Q(s_0,\cdot)$ alone, using the identical $\hat Q$.

Trajectory-level marginalization. Treat the whole set of retrieved clusters as one action and apply one-step OffCEM, or DSO-style kernel smoothing over the embedding of the retrieved set.

Fairness and ablations. All estimators share logs, $\hat Q$, embeddings, and a matched hyperparameter search (clipping thresholds, kernel bandwidths, $K$), each tuned on the same held-out policies. The key ablation removes the $\hat Q$ residual to give plain cluster importance sampling, and sweeps $K$ from 1 to the number of chunks. At $K=1$ the estimator reduces to the direct method, and at $K$ equal to the number of chunks it becomes chunk-level doubly robust. The proposal wins only if an interior $K$ is best.

Available reference numbers. The strongest one-step reference is from Off-Policy Evaluation for Large Action Spaces via Conjunct Effect Modeling. It reports a 99.1% MSE reduction versus IPS and 88.7% versus doubly robust estimation on synthetic tasks with up to 4,000 actions. We found no reported result on Lacuna for off-policy evaluation of retrieval or language-model policies on RULER, BabiLong, HotpotQA or MuSiQue. The only RULER numbers in the file are policy scores, not estimator errors: RULER-QA 73.17 for standard RLVR versus 88.90 for LongRLVR, from LongRLVR. We will use them only to confirm that our target policies span a realistic range.

Why not just…?

Why not just fit a value model and read off its prediction? This is the direct method, and it uses exactly our $\hat Q$, so the comparison isolates what the weighting adds. Prior one-step evidence says pure regression loses in large action spaces. POTEC and OffCEM both find misspecification bias when data per action is thin, and DSO reports a 5x gain over regression. That evidence comes from recommendation, not retrieval. If fitted-Q evaluation from Q-RAG's architecture is already accurate on these tasks, the $K=1$ endpoint of our sweep will win and we will report that.

Why not just treat the whole trajectory as one action and use a one-step marginalized estimator? This is the most serious alternative, because it avoids compounding entirely. Its weakness is that the probability of a set of retrieved clusters under the logging policy is not available in closed form. Each step's options depend on which specific chunk came before. It must therefore either be estimated, adding bias, or be approximated by ignoring order. Kernel smoothing over the embedding of the whole retrieved set also blurs the difference between getting hop two right and getting it wrong. The trajectory-level baseline is run head to head across hop counts. If it matches us at $T\le3$, the honest conclusion is that sequential structure only matters at longer horizons, and we would restrict the claim accordingly.

Why not just run the new policy online on a few hundred prompts? When the retriever is light and the answer model is small, this may be cheap enough, and a small online sample is unbiased. The budget-matched online baseline settles it directly. Our method must either reach lower error at equal cost, or be the only option when logs come from real users with no simulator, which is the case LongRLVR's synthetic-label pipeline does not cover. If online evaluation wins at equal cost on RULER-scale tasks, we will say so and keep the log-only setting as the contribution.

Why not just clip chunk-level weights? Clipping trades variance for bias that grows with context length, because the target policy's mass lands on chunks that were rarely logged. The context-length sweep below tests this directly against the clipped chunk-level doubly robust baseline.

Proposed Experiments

Primary evaluation. For each target policy, ground truth comes from many online rollouts. We report:

  • mean squared error of the estimated value, relative to the spread of values across target policies;
  • Spearman correlation of the estimated policy ranking with the true ranking;
  • regret of the policy each estimator would select.

These are measured on RULER variable tracking and RULER QA at 32K and 128K, on BabiLong at longer lengths, and on HotpotQA and MuSiQue.

Decisive check 1: context length. As chunks per document grow from roughly 250 to several thousand, chunk-level estimators' error should rise sharply. The cluster estimator's error should stay nearly flat. If it does not, the core mechanism fails.

Decisive check 2: hop count. Vary hop count from 2 to 5 at fixed length. The gap between cluster ratios and chunk ratios should widen multiplicatively, as the variance bound predicts.

Decisive check 3: controlled violation of local correctness. Inject a synthetic reward term that depends on which chunk within a cluster was chosen and interacts across hops. The measured bias should track the within-cluster error of $\hat Q$ as predicted by the bias bound. This tells practitioners when the estimator can and cannot be trusted.

Decisive check 4: cluster geometry and the V-curve. Compare K-Means clusters with value-aware clusters, and trace error against $K$ for each hop count. This tests whether the V-shaped curve from context clustering shifts toward finer clusters as horizons lengthen, as compounding bias would suggest.