18 min read
ReOPD — offline multi-turn distillation without environment rollouts
Online on-policy distillation forces LLM agents to execute live environment rollouts and query teacher models at every step, making multi-turn training prohibitively expensive. ReOPD replaces live environment interactions with replayed teacher prefixes while preserving on-policy student actions at the evaluated step. This eliminates tool calls during student training and speeds up rollout throughput by at least without degrading reasoning accuracy.
By the end you should be able to trace a student action along a replayed prefix, compute the geometric bridge weight between student and teacher occupancies, and derive the step-decay schedule that resolves the two-sided prefix trap.
Contents
Why online multi-turn distillation scales poorly
Why does standard multi-turn on-policy distillation become computationally intractable in tool-use environments?
Why does standard on-policy distillation in multi-turn tool environments become computationally intractable as agent training scales? In a multi-turn mathematical reasoning task with Python code execution, evaluating a student policy against an expert teacher policy requires generating fresh candidate actions and obtaining live environment observations across interaction steps. Because each policy update alters the student's trajectories, the training loop is forced to execute fresh environment rollouts and query teacher target distributions across newly visited interaction histories at every step [1].
The naive attempt to perform on-policy distillation executes this interactive loop live inside the training pipeline. In a standard setup, the student policy generates actions, sends code snippets to a live Python execution server, waits for output messages, and appends the new observation to build history . Because policy optimization modifies the student parameters at every gradient step, the student history distribution student history occupancy constantly changes. Consequently, the training loop cannot reuse past rollouts and must re-run the live Python environment for every updated batch. When scaling this process to complex agentic workloads that combine code interpreters, web retrieval tools, and databases, hosting and managing all execution environments concurrently introduces severe deployment complexity and hardware contention [2].
This fully online requirement creates a severe computational bottleneck. Generating fresh environment observations and querying teacher conditionals at every update step causes training throughput to collapse. Live execution latency dominates wall-clock time, tool execution servers require massive process concurrency, and hosting large teacher models alongside active environment containers consumes prohibitive memory resources.
A compelling alternative is off-environment prefix replay: replacing live execution with pre-collected teacher trajectories, where observations are drawn from recorded execution traces. Reusing teacher prefixes removes live environment interactions entirely, allowing offline trajectory pools to be shared across diverse tasks. However, this shift creates a new unresolved tension: while replaying static teacher prefixes eliminates environment overhead, it introduces sequence drift between teacher-generated prefixes and on-policy student actions.
The two-sided distribution shift
How does substituting teacher prefixes for student roll-ins create a trade-off between relevance and reliability?
Suppose our LLM agent is attempting a multi-turn mathematical reasoning problem using a Python code interpreter. At step , the student policy student policy generates flawed code, producing an execution error and a traceback history that the expert teacher policy never encountered during its own training. If we evaluate the student strictly on its own rollout history from student history occupancy, the training state is perfectly relevant to the student's operational distribution. However, when we query the teacher for a target distribution on this uncalibrated history, its predictions become erratic because the state lies outside the teacher's reliable domain.
Conversely, if we replace the student's rollout with a pre-collected trace from teacher history occupancy, every code block and environment output is pristine. The teacher delivers sharp, low-entropy target distributions, but the student never learns how to handle its own buggy code. This tension exposes the two-sided distribution shift [3]: prioritizing student relevance by sampling from student history occupancy corrupts teacher supervision, whereas prioritizing teacher reliability by sampling from teacher history occupancy leaves the student fragile to its own mistakes [4].
To quantify this trade-off, we compare the objective against an ideal target ideal improvement target, which evaluates the student on its own environment occupancy student history occupancy against the true optimal step action. When we substitute the ideal target with the teacher teacher policy on an arbitrary effective prefix distribution, the discrepancy between the ideal interactive objective and the replayed distillation loss is upper-bounded by two distinct mismatch terms [5].
The first term in the bound measures student occupancy mismatch via total variation distance , scaled by the uniform loss bound bounded loss constant [3]. This mismatch shrinks to zero only when the effective prefix distribution effective prefix distribution matches the student's live environment occupancy student history occupancy. The second term measures expected teacher unreliability , which remains small only when draws histories where the teacher's target distribution stays close to the ideal target [5].
Evaluating either extreme reveals why simple distribution choices fail [4]. Selecting zeroes out the occupancy mismatch, but as increases, student errors compound and drive upward as the teacher is queried on unfamiliar code tracebacks. Conversely, selecting minimizes teacher unreliability but maximizes occupancy mismatch . Because neither purely student-on-policy nor purely teacher-forced history distributions minimize both error terms simultaneously across all interaction steps, effective distillation requires a mechanism that explicitly balances relevance against reliability.
The geometric occupancy bridge
How can an effective history distribution balance student relevance against teacher reliability?
When an LLM agent solves a multi-turn math problem using a Python interpreter, training prefixes set both where the student learns and where the teacher is asked to supervise. If we sample prefixes strictly from the student's history occupancy student history occupancy, the student encounters states produced by its own past interpreter errors. However, as the student drifts off-track into malformed code contexts, the teacher policy teacher policy is queried on uncalibrated histories where its target conditionals become unreliable [4]. Conversely, sampling prefixes solely from teacher occupancy teacher history occupancy provides reliable target distributions, but leaves the student untrained on recovery paths. A naive linear mixture fails because it assigns mass to low-probability regions of either distribution without preserving the joint likelihood structure of valid multi-turn interaction traces.
To minimize both KL divergences to student occupancy student history occupancy and teacher occupancy teacher history occupancy, we need a formal interpolation between student and teacher history occupancies [6]. We define the optimal effective distribution optimal effective history distribution as the minimizer of a trade-off objective between student relevance and teacher reliability [7]:
Solving this constrained optimization problem yields the geometric occupancy bridge [8]:
The parameter operates as a continuous trade-off weight bridge interpolation weight [6]. Setting recovers pure student-on-policy roll-in, maximizing relevance at the expense of teacher reliability. Setting collapses the bridge to teacher-forced roll-in, guaranteeing reliable targets while ignoring student drift. Intermediate values select prefixes that are both reachable by the student's current interpreter actions and anchored within the teacher's reliable domain. Crucially, the optimal balance shifts across trajectory steps : at early steps, student and teacher occupancies heavily overlap (), whereas deep in a multi-turn reasoning trajectory, compounding errors degrade teacher reliability, pulling the optimal weight toward teacher support () [6].
Geometric bridge density as a function of occupancy ratio
Increasing shifts training density toward student-favored histories, while decreasing anchors density in teacher-supported regions.
This model isolates the geometric interpolation at step holding all other history variables fixed.
Instantiating this optimal geometric bridge directly requires evaluating density ratios between student and teacher occupancies across multi-turn trajectories [6]. However, exact density ratios across long sequences incur high variance, making direct sample reweighting unstable over extended horizons.
Step-decay sampling schedule
How does a position-dependent step decay approximate the exact geometric bridge weight?
When an LLM agent executes Python code across multiple interaction turns to solve a math problem, estimating the exact geometric bridge weight at step requires knowing how likely the student would have reached that specific execution history. Evaluating the exact density ratio between student and teacher history occupancies requires computing the cumulative likelihood ratio along the replayed teacher prefix. Because both policies evaluate on the identical teacher-recorded prefix , environment observation probabilities cancel out completely, leaving the per-history prefix likelihood ratio [9]:
Evaluating this ratio reveals a severe practical flaw. Because every historical action was chosen by the teacher, the student policy assigns it a lower probability than the teacher does, causing to decay exponentially toward zero as execution traces extend [9]. Estimating the exact normalized bridge weight creates extreme variance across individual trajectories, making loss gradients unstable [10].
However, empirical measurements show that the step index accounts for almost all variation in , so approximating the log-ratio by the average per-step KL divergence gives , where [9]. Exponentiating this approximation connects the bridge parameter directly to the step-decay base [11]:
This mapping replaces noisy per-history density ratios with a clean position-dependent schedule , whose normalization across the trajectory horizon yields step sampling probabilities . Instead of evaluating every position and multiplying losses by volatile weights, the training pipeline simply draws interaction step with probability from the offline trajectory pool and applies unweighted distillation on the student's generated action. Early code execution steps—where student prefix drift is minimal—are sampled frequently, whereas late high-shift steps are sampled exponentially less. This concentrates supervision on low-shift prefixes where teacher conditionals are reliable while eliminating per-history likelihood ratio variance [9].
We must verify whether training off-environment with prefix decay preserves distillation accuracy without executing tool calls.
This mapping replaces noisy per-history density ratios with a clean position-dependent schedule [9]. Normalizing across the trajectory horizon yields a step sampling probability [9]. Instead of evaluating every position and multiplying losses by volatile weights, the training pipeline simply draws interaction step with probability from the offline trajectory pool and applies unweighted distillation on the student's generated action [9]. Early code execution steps—where the student's prefix drift is minimal—are sampled frequently, whereas late steps—where replayed prefixes become high-shift surrogates—are sampled exponentially less [9]. This concentrates supervision on low-shift prefixes where teacher conditionals are reliable, while eliminating per-history likelihood ratio variance [9].
We must verify whether training off-environment with prefix decay preserves distillation accuracy without executing tool calls.
Off-environment prefix replay
How does ReOPD execute student step generation and teacher supervision without live tool execution?
When an LLM agent solves a mathematical reasoning problem across multiple interaction turns, executing Python code snippets at each step consumes significant compute and wall-clock time. In standard online on-policy distillation, the student policy student policy must evaluate its own action on-policy at step . To obtain the interaction history prefix , online distillation forces the student to execute live tool calls against the environment for every rollout. This creates a severe throughput bottleneck during student optimization. Can we provide genuinely on-policy training signals at step without executing a single live tool call?
A naive attempt to bypass live execution is pure off-policy teacher forcing—training the student solely to predict offline teacher tokens. But this fails to provide on-policy feedback: because the student never evaluates its own generated actions, it suffers from severe exposure bias when it branches off-trajectory during multi-turn inference.
ReOPD eliminates live environment calls while preserving on-policy evaluation by utilizing an offline teacher trajectory pool teacher trajectory pool. For a supervised step , the interaction prefix is replayed verbatim from a recorded teacher trace, including all previous teacher actions and environment observations . The student does not re-run Python code to reach step . Instead, it receives as a static context and autoregressively samples its own multi-token action [12].
Supervision is computed per generated token along the student's action . For each token position , the teacher policy teacher policy evaluates its target conditional using the student's own generated tokens as context. Because the evaluated contexts are sampled directly by the student, the distillation step is genuinely on-policy [12]. Crucially, because is replayed verbatim from , no action is executed in the environment and no observation is generated [13].
This off-environment prefix replay achieves zero tool calls during student training, bypassing process memory constraints and code interpreter deployment bottlenecks. Consequently, ReOPD achieves at least a speedup in rollout throughput relative to standard online distillation [14].
While off-environment prefix replay removes the operational bottleneck of online tool calls, it relies entirely on replayed teacher traces. It remains to test whether ReOPD maintains reasoning accuracy across diverse environment domains and under varying teacher-student capability gaps.
Regime-aware distillation performance
Under what environment conditions does ReOPD outperform standard online on-policy distillation?
In a multi-turn mathematical reasoning problem with a Python code interpreter, an LLM agent executes code across interaction steps. When standard online on-policy distillation rolls out the student policy student policy in a live execution environment, early student mistakes steer interaction into uncalibrated states where the teacher policy teacher policy was never trained. At these drifted histories, teacher supervision fails because the teacher's conditional action distribution is an unreliable proxy for true solution progress. One might assume that executing live student rollouts is essential for effective on-policy learning; however, when the capability gap between teacher and student is wide, forcing student-on-policy roll-ins actively degrades distillation quality. ReOPD resolves this trap by keeping the roll-in anchored to replayed prefixes replayed interaction prefix from the offline teacher trajectory pool teacher trajectory pool, evaluating the student step action student step action on states where teacher targets remain trustworthy [15].
This structural distinction divides multi-turn distillation into two clear environment regimes [15]. On complex mathematical reasoning tasks, where the teacher-student model gap is large, teacher reliability shift dominates. Evaluating a Qwen3-4B student under a Qwen3-4B teacher on Python-assisted math benchmarks, ReOPD achieves an average accuracy of , outperforming online OPD's . When scaling to a stronger Qwen3-8B teacher, ReOPD widens its advantage over online OPD ( vs average accuracy), precisely because teacher unreliability on drifted student rollouts becomes the primary performance bottleneck [16]. Conversely, in search and question-answering environments where the teacher remains reliable on student-induced histories, student occupancy shift dominates [15]. Here, ReOPD essentially matches online OPD ( vs average accuracy under a Qwen3-4B teacher) because teacher-anchored prefixes and student-induced histories nearly overlap [17].
ReOPD also scales seamlessly to multi-environment settings without added operational complexity. Training a single student agent across heterogeneous tool environments normally requires deploying live Python interpreters and search engines concurrently during every gradient update. By decoupling prefix collection from student optimization, ReOPD allows distinct domain teachers to build offline trajectory pools independently, which are then merged into a unified dataset for joint student training. On joint math and search benchmarks, a single student trained via ReOPD achieves math average and search average, matching online OPD while eliminating live environment hosting entirely [18]. This resolves our central throughline: LLM agents can learn from dense on-policy distillation off-environment with zero live tool calls during student training, achieving at least a speedup per rollout without degrading reasoning accuracy [14].
Transfer set
Put the pieces together
These questions combine mechanisms from more than one section. Work from the causal chain before opening the answer.
- 01
Suppose an engineer sets the step-decay parameter when training an agent on a turn Python math reasoning task, resulting in a uniform sampling distribution across steps. Combining the error bound from the two-sided prefix trap with the step-decay derivation, how does this choice affect the balance between student occupancy mismatch and expected teacher unreliability at late interaction steps (), and why does it degrade distillation performance?
Show answer
Setting forces a uniform sampling distribution , sampling deep interaction steps () with equal probability as step . As derived from the per-history likelihood ratio , the student-to-teacher density ratio decays exponentially with turn index . In terms of the geometric occupancy bridge , assigning equal sampling weight at large corresponds to keeping artificially high rather than letting to anchor deep prefixes in teacher support . On multi-turn code execution trajectories, over-sampling late-step teacher prefixes without position decay forces the student to evaluate actions on deep replayed prefixes where cumulative sequence drift is high. This fails to minimize the combined bound of total variation mismatch and expected teacher unreliability , degrading distillation accuracy relative to the step-decay schedule .
- 02
Consider a scenario where the student policy has already converged close to the teacher policy such that the average per-step KL divergence , but the multi-turn Python execution environment still suffers from high latency and tool server overhead. Combining the step-decay parameter mapping, off-environment prefix replay, and regime-aware performance mechanisms, what happens to the sampling schedule , execution tool calls, and overall distillation throughput?
Show answer
When the student-teacher policy gap vanishes (), the step-decay base approaches , making the step sampling distribution uniform across interaction turns . Because , student occupancy matches teacher occupancy , dropping total variation occupancy mismatch and teacher unreliability to near zero across all turns. Under off-environment prefix replay, the student generates step actions directly on replayed teacher prefixes from the offline trajectory pool . Because all intermediate observations are loaded directly from , the student optimization loop executes exactly zero live tool calls. This resolves our central throughline—how to perform on-policy distillation without live tool execution—by showing that replacing live rollouts with replayed teacher prefixes eliminates environment latency bottlenecks and speeds up rollout throughput by at least while preserving full reasoning performance.
References
- [1]Abstractabstract“Fully online OPD is costly because each update requires fresh student rollouts through the environment and teacher queries at visited histories.”
- [2]“With an increasing number of environments, the operational complexity grows for OPD due to the heavy deployment of the environments.”
- [3]“Second, even when histories are relevant to the student, the teacher may be unreliable on histories far from its own interaction support.”
- [4]“Fully student-on-policy OPD ( for all ) zeroes the occupancy term but not the reliability one: student-generated actions can steer the environment into histories unlikely under the teacher's own interaction process, especially at later steps where its conditional is a poorly calibrated target.”
- [5]Equation 4EQ4“\mathcal R^\star(\theta;\theta_{\mathrm{old}})”
- [6]“When the supports overlap, the solution is the geometric bridge”
- [7]“\rho_t^\star \in \arg\min_{\rho_t}”
- [8]“\rho_t^\star(h_t\mid x) \propto”
- [9]“so the exact weight's depth profile is geometric:”
- [10]“\label{eq:exact-weight}”
- [11]“\label{eq:kappa-map}”
- [12]“For each supervised step , the prefix is replayed \emph{verbatim} from the teacher trace -- all earlier actions and all observations are the teacher's.”
- [13]“No action is ever executed against the environment and no observation is ever generated, so no environment is queried.”
- [14]“Unlike OPD, which must execute fresh environment rollouts and tool calls during every student update, ReOPD replays teacher-recorded prefixes and therefore uses zero tool calls during student training. This also translates into faster updates: ReOPD is at least faster per rollout than OPD.”
- [15]“the teacher-anchored pool wins when the gap is large and ties student-on-policy OPD when the teacher is already reliable”
- [16]“With a Qwen3-4B teacher and Qwen3-4B student, ReOPD improves the average from to ; with a Qwen3-8B teacher, it improves from to ”
- [17]“With a Qwen3-4B teacher, OPD and ReOPD obtain and average accuracy, respectively;”
- [18]“ReOPD remains on par with OPD in both domains while avoiding online environment interaction during student training.”