betaFeedback

WorksComputer Science

Teaching Agents in their Own Style: Blackbox Teacher Distillation for Web Agents

Abstract

Frontier web agents using closed models have high inference and computational costs. Smaller open models can be an alternative, but to be performant, they require training supervision from a human or teacher model. Token-level teacher distillation is not an option for closed teachers as it needs access to the model's logits. The standard approach is to imitate teacher demonstrations offline, but it trains the student on states it has never visited, and in a style it does not write in. We introduce WebKD, where the teacher is the editor of the student's failures. Given a failed episode, the teacher finds the first point of mistake, and rewrites the student's reasoning traces, harness states, and actions from that point onward. The editing reveals that the teacher's corrections can be more surprising to the student than the student's own text. WebKD instead aims to edit minimally. In the data space, the teacher writes each correction in the student's style. In the objective space, the reasoning is weighted by its contribution to the action. A role-asymmetric KL anchor allows the corrected action to move freely while keeping the reasoning near the student's prior. On the TimeWarp benchmark, WebKD students gain about 5.5-10.7 pp over behavior cloning, outcome-reward RL, and teacher editing baselines. The performance transfers to unseen versions and to the live web in the OnlineMind2Web benchmark. WebKD opens a new way of distilling black-box models to improve the capabilities of open-weight web agents.

https://web-teach-kd.github.io/

Introduction

Agents built on the largest proprietary large language models (LLMs) now perform remarkably well on web tasks [30, 35]. Such a task hands the agent a goal and a browser, and asks it to navigate complex, changing interfaces, plan across tens of steps, and carry intermediate findings through to a final answer. Deploying these agents for everyday use is another matter. Frontier models have high latency because they are large reasoning models. The computational cost makes them less viable as agents that run in the background of daily work. Robotics faced a similar problem, which led to compact Vision-Language-Action (VLA) models distilled for real-time control [43, 15]. Web agents also need a small open-weight model that runs at interactive latency but carries the competence closer to its frontier teacher.

This raises the main challenge we address in this paper: how do we effectively transfer the competence of the black-box, teacher model to the small, more efficient model? Web tasks can be long-horizon or partially observed pages, and the agent must plan explicitly while reasoning in natural language [35]. The harness truncates the history to recent observations due to the limited context. So the agent also keeps a scratchpad memory, and what it writes there, together with its earlier responses, is the only state that persists across steps (de Chezelles et al., 2025) (§ 3.1).

Secondly, the outcome reward is a single value per episode, far too sparse to shape multiple structured decisions with reinforcement learning (RL) [29, 33]. Teacher supervision is denser, but the strongest teachers are black boxes that expose no internals or logits. Every distillation method that consumes the teacher’s next-token distribution, e.g., token-level knowledge distillation (KD), reverse Kullback–Leibler (KL) objectives, and on-policy distillation [7, 1, 22], is therefore unavailable. What a frontier teacher can emit is text. Our research asks how much of a black-box frontier teacher’s competence can be distilled into a small web agent through text alone.

The standard approach is behavior cloning, which involves sampling teacher demonstrations and fine-tuning the student on them offline [16]. For web agents, this is known to help substantially [9, 13], and it is where our pipeline begins. But behavior cloning creates two new problems. It trains the student only at states the teacher visits, so at deployment, small errors carry the student into states its supervision never covered, and the errors compound over the horizon [27]. Secondly, it trains the student on the teacher’s surface distribution, unintentionally importing a writing style that the small model cannot comfortably produce. Is offline imitation really the most a teacher has to offer?

The classical answer to this is DAgger [27], where the expert relabels the states the learner visits. However, DAgger corrects only the actions while a web agent’s generation is a structured response (Figure 1). With truncated history, the non-action parts of that response form the belief state that guides later decisions. Fixing the click while leaving the reasoning that led to it unchanged, therefore fixes the immediate mistake but not its source. Conversely, on-policy expert correction [18] gives control to the teacher from the point of failure and lets it finish the episode. So the completed suffix is the teacher’s trajectory, which is off-policy in state and style.

Figure 1. Overview of WEBKD. (Top) At step tt, the harness generates the observation history from the goal, accessibility tree, and previous responses. The web agent emits a five-component response conditioned on the observation history. The Think, Plan, and Step components carry their reasoning and running plan, the Memory component reads from and writes to the scratchpad memory, and only the Action component is executed in the web environment, which returns the next observation. (Bottom) The student is behavior-cloned on the teacher’s rollouts (P1) and then generates rollouts from the training tasks (P2). The teacher localizes each failure at t′t' (P3) and rewrites the faulty trajectory suffix in the student’s style (P4). The resulting corpus D\mathcal{D} trains the student under action informativeness weighing, and KL anchored objective of § 3.3.1–§ 3.3.2.

An alternative is to use the teacher as an editor of the student’s own failures. The teacher reads a failed episode, localizes the earliest erroneous step, and rewrites the student’s full structured response, reasoning, and harness traces included, from that step to the end. Each rewrite is a single-step teacher rollout on a state the student actually visited, so the supervision is on-policy. However, it is not on-policy in style. A frontier teacher’s corrections are surprising to the student, which are at several times the perplexity of the student’s own steps. This gap is especially large in the reasoning components, where perplexity can increase by up to an order of magnitude, while the action itself remains much closer to the student’s distribution.

Under uniform fine-tuning, the loss is largest where the supervision is most foreign, which is the teacher’s wording rather than its decisions. WEBKD attacks this perplexity premium by editing the rationale minimally. In data space, the teacher writes each correction in the student’s own style from in-context exemplars of the student’s writing. In objective space, each reasoning span is weighted by how much it raises the student’s probability of the corrected action. A role-asymmetric anchor allows the corrected action to move freely while keeping the reasoning close to the student’s prior. The student adopts the teacher’s decisions in full, while being closer to its own writing style.

Our contributions are as follows:

  • Problem. We formulate distillation from a black-box frontier teacher into a small web agent by using teacher-edits and identify a key obstacle, the on-policy perplexity premium (Defn. 1). The premium is the excess surprisal of the student on the teacher supervision, and it concentrates on the reasoning components rather than the action (Figure 2).

Perplexity premium by response components

Figure 2. The perplexity premium by response components against the student’s continuations, the teacher’s raw corrections, and the WEBKD’s corpus with in-context edits.

  • Method. We introduce WEBKD, a new distillation method that uses the teacher to edit the student’s failures without the teacher’s logits (Figure 1). The teacher localizes the first erroneous step and rewrites the subsequent reasoning traces, scratchpad memory, and actions in the student’s style instead of imitating teacher-style traces (§ 3.3). The student then trains under a novel objective function that weights each reasoning span by how much it informs the action (§ 3.3.1) and anchors the reasoning to the student’s prior (§ 3.3.2).

  • Evidence. On the TimeWarp benchmark, WEBKD lifts the performance of students by 5.5 – 10.7 pp across behavior cloning, outcome-reward RL, and teacher editing baselines using Qwen and Gemma models (Table 1). The gains translate to unseen TimeWarp versions, and the live web benchmark, OnlineMind2Web (Figure 4). Our ablations vary the source of the edits and styles, training objectives, and hyperparameters (Table 2, Table 3, Fig. 5).

ModelBaselinev1v2v3v4v5v6 (seen)
–Teacher (GPT-5.5)71.8±4.4371.8 \pm4.4371.8±4.4371.8 \pm4.4368.0±4.6068.0 \pm4.6068.0±4.6068.0 \pm4.6069.9±4.5269.9 \pm4.5270.9±4.5870.9 \pm4.58
Qwen 3.5 4BZero-Shot1.0±0.571.0 \pm0.571.0±0.571.0 \pm0.570.3±0.310.3 \pm0.311.6±0.711.6 \pm0.710.0±0.000.0 \pm0.001.0±0.571.0 \pm0.57
Behavior Cloning10.7±1.7610.7 \pm1.769.4±1.669.4 \pm1.669.7±1.689.7 \pm1.6810.7±1.7610.7 \pm1.765.2±1.265.2 \pm1.269.7±1.689.7 \pm1.68
Behavior Cloning (TW)27.5±2.5427.5 \pm2.5428.5±2.5728.5 \pm2.5727.8±2.5527.8 \pm2.5526.2±2.5026.2 \pm2.5028.2±2.5628.2 \pm2.5629.8±2.6029.8 \pm2.60
m-GRPO30.1±2.6230.1 \pm2.6227.2±2.5427.2 \pm2.5426.2±2.5026.2 \pm2.5028.2±2.5628.2 \pm2.5630.1±2.6130.1 \pm2.6130.4±2.6230.4 \pm2.62
Self/Student Edit25.2±2.4725.2 \pm2.4719.4±2.2519.4 \pm2.2527.2±2.5327.2 \pm2.5324.3±2.5624.3 \pm2.5623.3±2.6123.3 \pm2.6123.6±2.6223.6 \pm2.62
Off-policy Takeover24.4±2.4524.4 \pm2.4524.3±2.4424.3 \pm2.4425.2±2.4825.2 \pm2.4823.3±2.4123.3 \pm2.4127.2±2.5427.2 \pm2.5425.6±2.4925.6 \pm2.49
Student Re-style Edit28.8±2.5828.8 \pm2.5823.6±2.4223.6 \pm2.4223.7±2.4323.7 \pm2.4326.5±2.5226.5 \pm2.5228.3±2.5728.3 \pm2.5726.9±2.5326.9 \pm2.53
WEBKD37.9±2.7737.9 \pm2.7736.3±2.7336.3 \pm2.7335.3±2.7235.3 \pm2.7238.8±2.7738.8 \pm2.7736.9±2.7436.9 \pm2.7441.1±2.8041.1 \pm2.80
Qwen 3.5 9BZero-Shot0.0±0.000.0 \pm0.000.3±0.310.3 \pm0.311.6±0.711.6 \pm0.711.3±0.651.3 \pm0.650.0±0.000.0 \pm0.000.6±0.440.6 \pm0.44
Behavior Cloning12.3±1.8712.3 \pm1.8710.0±1.7110.0 \pm1.716.8±1.436.8 \pm1.4311.7±1.8211.7 \pm1.824.9±1.234.9 \pm1.2312.3±1.8712.3 \pm1.87
Behavior Cloning (TW)25.9±2.4925.9 \pm2.4924.3±2.4424.3 \pm2.4422.0±2.3622.0 \pm2.3625.2±2.4725.2 \pm2.4726.2±2.5026.2 \pm2.5025.2±2.4725.2 \pm2.47
m-GRPO26.9±2.5226.9 \pm2.5227.8±2.5427.8 \pm2.5428.8±2.5828.8 \pm2.5831.1±2.6231.1 \pm2.6231.4±2.6531.4 \pm2.6526.5±2.5126.5 \pm2.51
Self/Student Edit22.3±2.3722.3 \pm2.3723.2±2.4023.2 \pm2.4022.7±2.3822.7 \pm2.3825.7±2.4925.7 \pm2.4922.7±2.3822.7 \pm2.3823.0±2.3923.0 \pm2.39
Off-policy Takeover28.4±2.5728.4 \pm2.5725.4±2.4825.4 \pm2.4829.4±2.5929.4 \pm2.5930.1±2.6130.1 \pm2.6127.3±2.5327.3 \pm2.5325.0±2.4625.0 \pm2.46
Student Re-style Edit17.3±2.1517.3 \pm2.1519.5±2.2519.5 \pm2.2518.7±2.2218.7 \pm2.2214.4±2.0014.4 \pm2.0016.4±2.1016.4 \pm2.1020.2±2.2820.2 \pm2.28
WEBKD34.6±2.7134.6 \pm2.7132.3±2.6632.3 \pm2.6632.4±2.6632.4 \pm2.6634.5±2.7034.5 \pm2.7034.9±2.7134.9 \pm2.7134.6±2.7134.6 \pm2.71
Gemma 4 E4BZero-Shot1.9±0.781.9 \pm0.787.8±1.537.8 \pm1.537.8±1.537.8 \pm1.531.9±0.771.9 \pm0.773.9±1.103.9 \pm1.102.6±0.902.6 \pm0.90
Behavior Cloning17.5±2.1617.5 \pm2.1616.5±2.1116.5 \pm2.1118.4±2.2018.4 \pm2.2015.5±2.0615.5 \pm2.0616.5±2.1116.5 \pm2.1119.4±2.2519.4 \pm2.25
Behavior Cloning (TW)28.2±2.5628.2 \pm2.5628.2±2.5628.2 \pm2.5632.0±2.6532.0 \pm2.6530.1±2.6130.1 \pm2.6128.8±2.5828.8 \pm2.5829.4±2.5829.4 \pm2.58
m-GRPO16.5±2.1116.5 \pm2.1114.6±2.0114.6 \pm2.0117.5±2.1617.5 \pm2.1618.4±2.2018.4 \pm2.2014.6±2.0114.6 \pm2.0120.7±2.3020.7 \pm2.30
Self/Student Edit22.3±2.3722.3 \pm2.3724.3±2.4424.3 \pm2.4421.4±2.3321.4 \pm2.3322.3±2.3722.3 \pm2.3721.7±2.3421.7 \pm2.3423.0±2.3923.0 \pm2.39
Off-policy Takeover29.8±2.6029.8 \pm2.6028.2±2.5628.2 \pm2.5629.1±2.5829.1 \pm2.5830.1±2.6130.1 \pm2.6133.0±2.6633.0 \pm2.6634.3±2.7034.3 \pm2.70
Student Re-style Edit20.4±2.2920.4 \pm2.2925.2±2.4725.2 \pm2.4723.3±2.4023.3 \pm2.4024.3±2.4524.3 \pm2.4523.3±2.4023.3 \pm2.4028.2±2.5628.2 \pm2.56
WEBKD37.2±2.7537.2 \pm2.7534.0±2.6934.0 \pm2.6937.9±2.7637.9 \pm2.7636.6±2.7436.6 \pm2.7438.8±2.7738.8 \pm2.7739.8±2.7839.8 \pm2.78

Table 1. Success rate (%) on the TimeWarp test split, in domain on v6 and on the five held-out versions v1–v5. Results are averaged over three runs with the standard error as the subscript.

Stacked bar chart of success rate on Online-Mind2Web

Figure 4. Success rate on Online-Mind2Web for the Qwen-3.5 4B and 9B students. The contributions are stacked across easy, medium, and hard categories.

ESSSVariantS.R. ↑
TTTeacher takeover (off-policy)17.48±2.16
TTTeacher edit + teacher style33.01±2.68
TSic_{\mathrm{ic}}Teacher edit + student style (in-context)41.10±2.80
TSinf_{\mathrm{inf}}}Teacher edit + student re-style (2-pass)25.89±2.49
S/TS/TStudent proposes, teacher judges/fixes27.83±2.55
SSStudent-only edit24.27±2.44

Table 2. Edit–style ablation. Teacher edits paired with in-context student style perform best. Qwen-3.5 4B baselines are trained using LWDL_{\mathrm{WD}}, KL rationale anchor at β=0.03\beta= 0.03. ES: Edit Source; SS: Style Source. T = Teacher, S = Student.

Lossw/ KLw/o KL
LCEL_{\mathrm{CE}}37.43±2.7536.25±2.73
LWDL_{\mathrm{WD}}41.10±2.8038.51±2.77
LGNDL_{\mathrm{GND}}35.92±2.7336.03±2.73
LCONSL_{\mathrm{CONS}}37.54±2.7535.81±2.73
LPPLL_{\mathrm{PPL}}37.54±2.7533.01±2.68

Table 3. Loss ablation. Token weightings on the filtered teacher rollouts, each with and without the KL rationale anchor at β=0.03\beta= 0.03 using the Qwen-3.5 4B model.

Related Work

Web Agents

Web agents, LLM-driven agents that operate a browser on a user’s behalf [5], are a subcategory of computer-use agents, which perceive rendered user interfaces and act through UIlevel commands [34]. The benchmark ecosystem spans curated demonstrations [5], sandboxed sites [42], live websites [8], and unified harnesses (de Chezelles et al., 2025). TimeWarp [13] additionally varies the era of the interface and tests robustness to temporal UI change. On these suites, proprietary frontier LLMs reach strong success rates, but their cost and latency make them impractical as always-on daily drivers. That gap motivates the small open-weight students this paper targets.

Training pipelines for such students span imitation and RL. WebRL [24], WebAgent-R1 [33], and DigiRL [2] train with outcome-reward RL and inherit its sparse signal, while OpenWebVoyager [9] and TimeWarp [13] fine-tune on teacher demonstrations, the recipe we start from. We differ in what happens after imitation. The teacher corrects the student’s own failures instead of supplying more demonstrations or rewards. Closest to us is WebCoT [11], which also distills reconstructed chain-of-thought rationales. However, the teacher rewrites stored records with template heuristics against observations simulated in the style of WebDreamer (Gu et al., 2025), and it does not localize the first fatal step before rewriting. WEBKD edits actual failures against the observations the student saw from the localized step in the student’s own style, using both the data and training objective.

Knowledge Distillation

Knowledge distillation transfers a teacher’s behavior to a smaller student [10], classically by matching token-level distributions or by fine-tuning on teacher generations at the sequence level [16]. For LLMs, the white-box distillation methods sharpen this line of work with reverse-KL objectives [7], on-policy distillation that scores student-sampled prefixes under the teacher [1, 22], and skew-divergence stabilizations [17]. All of them consume the teacher’s next-token distribution over a shared vocabulary. Black-box agents do not expose these, which forces distillation through text only. This introduces the notion of a perplexity premium (§ 3.2), which has previously been observed with LLM distillation [25] and is one of our paper’s main focuses.

A second lineage imitates the expert at the learner’s own states. DAgger (Ross et al. [27]) showed that relabeling learner-visited states turns quadratic compounding error into linear error, and LLM-era variants revive the recipe through turn-level policy interpolation (Li et al. [19]), mid-trajectory expert takeover (Lauffer et al. [18]), and iterated fine-tuning on privileged feedback (Choudhury & Sodhi [3]). We keep the state-distribution insight but change the label. Our teacher rewrites the full structured response offline instead of relabeling actions online. A third line removes the external teacher. Rejection fine-tuning keeps self-generated successes ([39, 38]), and on-policy self-distillation conditions the same model on privileged information such as a gold solution (Zhao et al. [40]), consensus (Li et al. [21]), or rich feedback (Hüböter et al. [12]), with agentic variants that target failure-relevant spans ([37, 20]). Self-distillation presupposes the competence the model already has, which a 4B student on realistic web tasks typically lacks (Table 1). So we keep an external frontier teacher and hold its supervision close to the student’s own states and style.

Methodology

Background

Web tasks as POMDP. A web task is specified by a natural-language goal gg on an interactive browser environment ee ([42] (de Chezelles et al. 2025)). Performing a web task is naturally formalized as a finite-horizon partially observable Markov decision process (POMDP) (Kaelbling et al. [14]) ⟨S,A,O,T,T0,O,R⟩\langle\mathcal{S}, \mathcal{A}, \mathcal{O}, \mathcal{T}, \mathcal{T}_0, \mathcal{O}, \mathcal{R} \rangle, with a step budget of TT actions per episode. The underlying browser state st∈Ss_t \in\mathcal{S} contains the full document object model (DOM), session, and site state, and is never observed directly. The initial state is drawn as s0∼T0s_0 \sim\mathcal{T}_0. The agent receives the rendering ot=O(st)∈Oo_t = \mathcal{O}(s_t) \in\mathcal{O}, in the form of HTML or an AXTree. An LLM policy πθ\pi_\theta generates a structured response yt∼πθ(⋅∣ht)y_t \sim\pi_\theta(\cdot\mid h_t) autoregressively, conditioned on the observation history hth_t. The browser-level action at∈Aa_t \in\mathcal{A}, e.g. click('63'), is deterministically parsed from yty_t and executed, producing ot+1o_{t+1} through the effectively deterministic transition T\mathcal{T}. The reward is sparse and terminal: R∈{0,1}R \in\{0, 1\}, assigned once at the end of the episode. The task goal gg is rendered into every observation, so the full interaction history is (o1:t,y1:t−1)(o_{1:t}, y_{1:t-1}). Carrying several high-dimensional observations (a single AXTree runs to thousands of tokens) overflows the context window, so the history is truncated to the most recent observation together with the full response history, ht=(ot,y1:t−1)h_t = (o_t, y_{1:t-1}).

Web harness. Between the policy and the browser sits the harness, the interface that turns the raw POMDP into an agentic loop. A harness also maintains its internal state across steps, namely the response history y1:t−1y_{1:t-1}, which carries the scratchpad memory sms_m as the sequence of memory components emitted so far (§A.4). At step tt, the harness (i) generates the observation history hth_t, (ii) obtains the structured response yt∼πθ(⋅∣ht)y_t \sim\pi_\theta(\cdot\mid h_t), (iii) parses the action fparse(yt)f_{\mathrm{parse}}(y_t), and (iv) executes the action to advance the environment st+1=T(st,at)s_{t+1} = \mathcal{T}(s_t, a_t) and ot+1=O(st+1)o_{t+1} = \mathcal{O}(s_{t+1}).

Agent response. The harness enforces a five-component response, yt=⟨ytthink,ytplan,ytstep,ytmemory,ytaction⟩=⟨T,P,S,M,A⟩y_t = \langle y_t^{\mathrm{think}}, y_t^{\mathrm{plan}}, y_t^{\mathrm{step}}, y_t^{\mathrm{memory}}, y_t^{\mathrm{action}} \rangle= \langle\mathrm{T}, \mathrm{P}, \mathrm{S}, \mathrm{M}, \mathrm{A} \rangle, generated sequentially (Figure 1) (de Chezelles et al. (2025)). think\mathrm{think} tokens constitute the free-form reasoning grounded in the current observation, plan\mathrm{plan} tokens form the running, numbered multi-step plan, re-emitted and revised at every step, the step\mathrm{step} token(s) is a single integer naming the current plan step, memory\mathrm{memory} tokens are the agent’s interface to the scratchpad memory sms_m (§A.4), and action\mathrm{action} tokens form one executable browser command. Only the action\mathrm{action} tokens (ytaction=aty_t^{\mathrm{action}} = a_t) interact with the environment. Every other component acts on the harness state alone and enters future contexts as part of the observation history hth_t.

We provide additional preliminary discussion on behavior cloning (§A.1), knowledge distillation (§A.2), and the black-box constraint (§A.3) in the appendix.

Perplexity Premium

Teacher edits are high-perplexity text for the student. The perplexity of a response yy under a policy π\pi with context xx,

PPL⁡π(y∣x)=exp⁡(−1∣y∣∑ilog⁡π(yi∣x,y<i)),(1)\operatorname{PPL}_{\pi}(y \mid x) = \exp\left(-\frac{1}{|y|}\sum_i \log\pi(y_i \mid x, y_{<i})\right), \tag*{(1)}

measures how natural the text is to that policy. 1 means the policy would have emitted it with certainty, and each unit of log-perplexity is a nat of average per-token surprise. The relative quantity that matters for training is the premium the student pays on its supervision.

Definition 1 (On-policy perplexity premium). For a step with student response yy and supervision target y∗y^* at the same observation history hh, the premium is the excess per-token surprisal, under the behavior-cloned student πθBC\pi_{\theta_{\mathrm{BC}}} (§A.1), of the supervision relative to the student’s own text:

Π(y∗,y)=1∣y∗∣∑i−log⁡πθBC(yi∗∣h,y<i∗)−1∣y∣∑i−log⁡πθBC(yi∣h,y<i).(2)\Pi(y^*,y)=\frac{1}{|y^*|}\sum_i-\log\pi_{\theta_{\mathrm{BC}}}(y_i^* \mid h,y_{<i}^*)-\frac{1}{|y|}\sum_i-\log\pi_{\theta_{\mathrm{BC}}}(y_i \mid h,y_{<i}). \tag*{(2)}

This premium is one of the obstacles to distilling a frontier teacher through text. As shown in Figure 2, the teacher edits are high-perplexity for the student, while WEBKD’s corpus stays close to the student’s own continuations. Per-token cross-entropy is the surprisal inside Eq. (1), and under uniform SFT, the loss is largest on the tokens most foreign to the student. On raw teacher edits, those are mostly the rationale tokens. The action tokens that fix the failure carry only a few percent of the loss. The surprising spans mix the teacher’s style with its content and reasoning. What it shows is where uniform SFT spends its loss, which motivates the objective of Eq. (5). Any method that trains on teacher edits must address the premium. Our method attacks it from both sides. In data space, before training, the correction is written in the student’s own style (P4 of § 3). In objective space, during training, the learning signal is concentrated on the tokens that inform the action (§ 3.3.1), and the rationale is anchored to the student’s own prior, which damps the premium the student absorbs and caps it per token once β\beta exceeds the threshold of Corollary 1 (§ 3.3.2).

Web Knowledge Distillation (WebKD)

The core of WEBKD is to correct the student’s decisions at the states it visited, rewriting only the steps from the failure onward. How can the student policy be improved while minimizing the student’s surprisal to teacher edits? WEBKD starts from a student agent fine-tuned to replicate the teacher (P1). We then collect rollouts from the fine-tuned student agent and keep its failures (P2). The edit itself is a two-stage teacher intervention: where did the student fail? (P3), and how should the teacher correct it? (P4). The corpus of corrected trajectories trains the student under a premium-aware objective: action-informative token weighting (§ 3.3.1) and a role-asymmetric anchor to the student’s prior (§ 3.3.2). Figure 1 gives an overview, and Algorithm 1 states the full method. We characterize in closed form the per-token target of the WEBKD objective (Proposition 2) and bound the student’s failure rate by the teacher’s localization and correction errors plus the student’s own disagreement with the corrected process (Theorem 1).

P1: Behavior cloning on teacher rollouts. WEBKD first replicates the teacher rollouts on the training tasks via behavior cloning at the sequence level. For the teacher πθT\pi_{\theta_T} acting as the agent under the same harness, the base model πθ0\pi_{\theta_0} is fine-tuned on the teacher demonstration trajectories DT={τn}n=1N\mathcal{D}_T=\{\tau_n\}_{n=1}^{N}, where each τn=(h1,y1,…,hT,yT)\tau_n=(h_1,y_1,\ldots,h_T,y_T) is a closed-loop teacher rollout, yi∼πθT(⋅∣hi)y_i\sim\pi_{\theta_T}(\cdot\mid h_i), kept only if its terminal reward is R(τn)=1R(\tau_n)=1. Training uses the uniform BC objective LBC\mathcal{L}_{\mathrm{BC}} of Eq. (6) to produce πθBC\pi_{\theta_{\mathrm{BC}}}, which is then frozen and reused in the following phases.

P2: Student on-policy rollout. We collect on-policy rollouts from the behavior-cloned student on the training tasks. Each rollout is generated by the agentic loop of § 3.1, every response drawn from the student’s own policy at a context the student itself reached, yt∼πθBC(⋅∣ht)y_t\sim\pi_{\theta_{\mathrm{BC}}}(\cdot\mid h_t), and we write T∼πθBC\mathcal{T}\sim\pi_{\theta_{\mathrm{BC}}} for the induced trajectory distribution. DBC\mathcal{D}_{\mathrm{BC}} collects these rollouts. The failed trajectories Df(BC)={τ∈DBC:R(τ)<1}\mathcal{D}_{f(\mathrm{BC})}=\{\tau\in\mathcal{D}_{\mathrm{BC}}:R(\tau)<1\} become the substrate for editing, and the solved episodes are kept as a style pool Ds(BC)={τ∈DBC:R(τ)=1}\mathcal{D}_{s(\mathrm{BC})}=\{\tau\in\mathcal{D}_{\mathrm{BC}}:R(\tau)=1\}, mined for in-context exemplars in P4. Every observation in Df(BC)\mathcal{D}_{f(\mathrm{BC})} has been visited by the student, which places the teacher’s supervision of the following phases within the student’s own state distribution.

P3: Failure localization. For each failed trajectory, the teacher first localizes the error to prevent editing the correct steps. We establish that web trajectories carry enough structure for the “point of failure” to be a well-defined property of the trajectory (§B.2). The teacher call is an estimator of t⋆t^{\star}, reads the full trajectory τ∈Df(BC)\tau\in\mathcal{D}_{f(\mathrm{BC})} and returns an index, t′=Loc⁡(τ)∈{1,…,T}t^{\prime}=\operatorname{Loc}(\tau)\in\{1,\ldots,T\}, the earliest step whose action sets the trajectory on the path to failure. Localization splits the trajectory into a replayed prefix τp=(h1,y1,…,ht′−1,yt′−1)\tau_p=(h_1,y_1,\ldots,h_{t^{\prime}-1},y_{t^{\prime}-1}), which is kept verbatim, and a faulty suffix τs=(ht′,yt′,…,hT,yT)\tau_s=(h_{t^{\prime}},y_{t^{\prime}},\ldots,h_T,y_T), which will be rewritten.

P4: Teacher editing in the student’s style. After localization, the teacher corrects the structured response of every step in the faulty suffix. Each correction is conditioned on the observation the student saw at that step, re-rendered by replaying the student’s original actions in the deterministic container, so the teacher sees exactly what the student saw. The correction query also carries the student’s response style in context. The corpus targets are

yk⋆=yk∀k<t′  (replay),yk⋆∼πθT(⋅∣hk,Ds(BC))∀k≥t′  (edit),(3)y_k^{\star}=y_k\quad\forall k<t^{\prime}\;(\text{replay}),\qquad y_k^{\star}\sim\pi_{\theta_T}\left(\cdot\mid h_k,\mathcal{D}_{s(\mathrm{BC})}\right)\quad\forall k\geq t^{\prime}\;(\text{edit}), \tag*{(3)}

where each edit is a 1-step rollout of the teacher policy at the student’s context. πT\pi_T is conditioned on the observation history hkh_k the student saw (the same rendered goal, AXTree, and response history) and on in-context exemplars from the student’s style pool Ds(BC)\mathcal{D}_{s(\mathrm{BC})}, one independent call per step. The edited structured response yk⋆y_k^{\star} comprises the edited tokens ⟨T⋆,P⋆,S⋆,M⋆,A⋆⟩\langle\mathrm{T}^{\star},\mathrm{P}^{\star},\mathrm{S}^{\star},\mathrm{M}^{\star},\mathrm{A}^{\star}\rangle (Details in §B.3).

Action-informative token weighting

P4 first lowers the premium in data space by having the teacher write in the student’s style. It cannot lower it to zero without giving up the correction. Some premium must be paid, and Figure 2 shows that on raw teacher edits, it falls almost entirely on the rationale components. The question for the objective is therefore which rationale tokens are worth their premium.

We ask, which tokens carry the learning signal? A rationale span is worth its premium to the extent that it changes the action, so Eq. (4) ranks the spans of each step by their measured effect on the student’s probability of the corrected action. Second, how far the policy may move? Eq. (5) adds a role-asymmetric anchor that damps how far the rationale moves toward the teacher’s phrasing while the action follows the teacher in full. Together, the objective pays the premium mainly where it buys the action. We weigh each rationale span by how much it contributes to the decision that follows.

Let ss be a non-action segment, a sentence or clause of the edited rationale ⟨T⋆,P⋆,M⋆⟩\langle\mathrm{T}^{\star},\mathrm{P}^{\star},\mathrm{M}^{\star}\rangle. Its leave-one-out contribution to the teacher’s corrected action, measured under the student is

Δs=log⁡πθBC(a⋆∣h,y<a⋆)−log⁡πθBC(a⋆∣h,y<a⋆∖s),s∈⟨T⋆,P⋆,M⋆⟩,(4)\Delta_s=\log\pi_{\theta_{\mathrm{BC}}}(a^{\star}\mid h,y^{\star}_{<a})-\log\pi_{\theta_{\mathrm{BC}}}(a^{\star}\mid h,y^{\star}_{<a}\setminus s),\quad s\in\langle\mathrm{T}^{\star},\mathrm{P}^{\star},\mathrm{M}^{\star}\rangle, \tag*{(4)}

where a⋆=⟨A⋆⟩a^{\star}=\langle\mathrm{A}^{\star}\rangle denotes the teacher-edited action tokens, hh is the observation history, y<a⋆=⟨T⋆,P⋆,S⋆,M⋆⟩y^{\star}_{<a}=\langle\mathrm{T}^{\star},\mathrm{P}^{\star},\mathrm{S}^{\star},\mathrm{M}^{\star}\rangle is the part of the edited response that precedes the action, so both terms are teacher-forced log-probabilities of the action tokens, and y<a⋆∖sy^{\star}_{<a}\setminus s is that prefix with segment ss deleted. As Δs\Delta_s is the student’s own credit assignment over the teacher’s rationale, it needs no teacher logits and is computable in the black-box setting. Perplexity says how foreign a span is to the student. Δs\Delta_s says how much the span raises the student’s probability of the corrected action, and two spans can be equally foreign while differing in this. The weighting in §B.4 ranks the spans of a step by Δs\Delta_s, so, outside the dead zone of Eq. (10) and when these spans are unique, the span that moves the action the most keeps full weight, and the span that moves it the least drops to the floor. Hence, the premium is paid mainly where it changes the decision rather than where it only changes the wording or style. Details on the action informativeness mapped to the WebKD loss have been provided in §B.4.

Role-asymmetric Anchoring and the WebKD Objective

The weighting decides which spans contribute to the action, but does not bound the magnitude of their contribution. A decisive span in ⟨T∗⟩\langle\mathrm{T}^{*} \rangle keeps full weight, and fitting it under the weighed SFT objective asks the student to fully absorb that span’s influence. As this could cause SFT to move the policy further than intended, we add a KL penalty [10] toward πθref≡πθBC\pi_{\theta_{\mathrm{ref}}} \equiv\pi_{\theta_{\mathrm{BC}}}, the frozen checkpoint of each run. The KL acts on the rationale tokens ⟨T,P,M⟩\langle\mathrm{T}, \mathrm{P}, \mathrm{M} \rangle only, i.e., it pulls these tokens toward the student’s prior and leaves the non-rationale ⟨A,S⟩\langle\mathrm{A}, \mathrm{S} \rangle tokens free to drift. With β≥0\beta\ge0 the anchor strength and γi∈[0,1]\gamma_i \in[0,1] a per-token role mask, the WebKD objective is

LWD=∑i∈Twi CEi∑i∈Twi⏟LSW+β⋅∑i∈Tγi kli∑i∈Tγi⏟LKL(5)\mathcal{L}_{\mathrm{WD}} = \frac{\sum_{i\in T} w_i\,\mathrm{CE}_i}{\underbrace{\sum_{i\in T} w_i}_{\mathcal{L}_{\mathrm{SW}}}} + \beta\cdot \frac{\sum_{i\in T}\gamma_i\,\mathrm{kl}_i}{\underbrace{\sum_{i\in T}\gamma_i}_{\mathcal{L}_{\mathrm{KL}}}} \tag*{(5)}

where di:=log⁡πref−log⁡πθ(yi∗)d_i := \log\pi_{\mathrm{ref}} - \log\pi_{\theta}(y_i^*), kli:=edi−di−1\mathrm{kl}_i := e^{d_i} - d_i - 1, and πθWD\pi_{\theta_{\mathrm{WD}}} is the student produced. We note that γi\gamma_i is role-asymmetric: γi=1\gamma_i = 1 on the ⟨T,P,M⟩\langle\mathrm{T}, \mathrm{P}, \mathrm{M} \rangle tokens and γi≈0\gamma_i \approx0 on ⟨A,S⟩\langle\mathrm{A}, \mathrm{S} \rangle, so the student is free to adopt the teacher’s corrected decisions while being held near its prior on deliberation. Normalizing by ∑iγi\sum_i \gamma_i makes β\beta a penalty per anchored token, comparable across masks that cover different numbers of tokens. Because kli\mathrm{kl}_i is evaluated on corpus tokens rather than on samples from πθ\pi_{\theta}, it is a pointwise anchor penalty on the target sequence. Details on the intuition of update in §E.

Experiments

We organize our experiments around four research questions: RQ1 (performance). Does WEBKD’s teacher edit distillation outperform behavior cloning, outcome-reward RL, or other methods of teacher edit? RQ2 (transfer). Do the gains survive interface versions never seen in training, and the live web? RQ3 (edit-style). Who should edit the student’s decisions and in whose style? RQ4 (objective). Which tokens should the loss emphasize, and how should the policy be anchored?

Experimental setup

We describe our setup concisely here and include additional details in the Appendix (§ 8).

Models, Harness, Baselines. We compare latest open-weight models: Qwen-3.5 4B and 9B [31], and Gemma 4 E4B [31], in BrowserGym with the AgentLab harness (de Chezelles et al., 2025). We evaluate (a) zero-shot, (b) vanilla behavior cloning on actions, and the TimeWarp approach on the full response [13], (c) outcome-based RL baseline using multi-turn Group Relative Policy Optimization (m-GRPO) [33], and (d) black-box distillation baselines on student self-editing, off-policy takeover with the teacher completing the trajectory, the teacher prompting the student to restyle the edits, and (e) our method, WEBKD. The average results of three seeds are reported with the standard error.

Benchmarks. We evaluate on: (a) TimeWarp (TW) [13], a containerized web benchmark with websites from different eras of the internet, and (b) OnlineMind2Web (OM2W) [35], a live web benchmark with realistic tasks using real user workflows.

Results

WEBKD outperforms every baseline on the seen distribution (RQ1). WEBKD improves over the strongest baseline by 10.7pp for Qwen 3.5 4B, 8.1pp for Qwen 3.5 9B, and 5.5pp for Gemma 4 E4B, on the seen TimeWarp version v6 (Table 1). Zero-shot students are near 0% on every version, so the task is out of reach without training. Behavior cloning is competitive only when non-action tokens are included in the loss (BC-TW). No single alternative is reliably second best. m-GRPO is the strongest baseline on both Qwen models, but falls on Gemma. The other teacher-text baselines show the opposite pattern. Off-policy takeover is the strongest baseline on Gemma (34.3%), but every teacher baseline trail m-GRPO on either the Qwen models.

The gains hold on unseen versions and transfer to the live web (RQ2). On the unseen versions v1–v5, WEBKD beats the strongest baseline by 3.0–10.6pp. Once a shift itself costs little once a student is trained, and the seen–unseen gap stays below 5pp. WEBKD’s gains hold on the live web, where Online-Mind2Web’s numbers are low for all methods (below 8%, Figure 4). WEBKD is the only method that clearly separates from the rest, roughly doubling the strongest baseline for the 9B student. The gains are mostly concentrated on the easy tasks, which have a shorter horizon.

The teacher should edit in the student’s style, but minimally (RQ3). Following Table 2, off-policy takeover underperforms as it drifts too far from the states the student has visited. Edits or suggestions written by the student are worse still, which we can attribute to the student lacking a reliable sense of its own correctness. Asking the student to restyle the teacher’s edit on a second pass can also undermine the rationale. This is most evident on Qwen 3.5 9B, where the student re-style edit is a weaker baseline (Table 1). Although vanilla teacher editing works, its outputs deviate more from the student’s style and carry a larger perplexity premium (Figure 2). In-context student re-styling, as used by WEBKD, stays closer to the student distribution and outperforms it by 8.1pp.

Loss should emphasize action informativeness, and anchor the rationale (RQ4). Table 3 compares token weightings of the loss, with and without the KL anchor on the rationale. LWDL_{\mathrm{WD}} with the kl anchor (Eq. (5)) outperforms the other token-weighting schemes (§C.2) by 3.6pp. Sweeping the anchor strength shows that β=0.03\beta= 0.03 gives the highest success with rationale masking (Figure 5).

Success rate as a function of KL coefficient

Figure 5. Success rate of Qwen-3.5 4B on TimeWarp v6 as a function of the anchor strength β\beta with LWD\mathcal{L}_{\mathrm{WD}}, anchoring the rationale tokens or all tokens. The dashed line is without KL.

Discussion. Behavior cloning for more epochs doesn’t simply improve performance like WEBKD (§D.1). Teacher capability matters. With the same prompts, states, and style exemplars, using Claude Opus 5 or Qwen-3.8 27B as the editor trains students to 33.3% and 26.9%, versus 41.1% with GPT-5.5. As Qwen-3.8 is a smaller, less-performant model, the distilled student’s performance is worse. Why can’t students self-improve? On average, self/student edit falls below BC (TC) on every backbone (Table 1). This is consistent with the findings on RQ3, i.e., without an external signal, the student cannot reliably tell which of its own decisions were wrong. How does WEBKD affect the behavior of the student? It mostly prunes redundant actions, e.g., scrolling nearly disappears (−99.7%) and key presses drop by 24.5% (Figure 6). send_msg rises by 12.3%, indicating higher task completion rate. Where do the gains come from? Our analysis reveals WEBKD’s strongest gains come from verifying the steps and answer +14.6pp and exiting loops +9.4pp. Detailed failure analysis (§D.2), and analysis of the improvements against behavior cloning (§D.3) have been provided in the Appendix.

Bar chart showing changes in action distribution before and after teacher distillation

Figure 6. Change in action distribution before and after teacher distillation using WE-BKDfor the Qwen-3.5 4B baseline.

Conclusion

Small, open-weight web agents are key to making web use automation widespread and accessible. Frontier agents have become highly capable, and distilling them into smaller models is a natural next step. Yet closed frontier models expose only their generated text, which rules out logit-based distillation. WEBKD addresses this by turning the teacher into an editor of the student’s failures. It rewrites failed episodes in the student’s own style and trains on them, using an objective that weights tokens based on action informativeness and a role-asymmetric KL anchor. Although WEBKD produced strong gains, the student still reaches only about half of the teacher’s success rate, leaving substantial room for improvement. We hope this work spurs further research on black-box distillation and helps narrow the gap between closed frontier models and small open-weight agents.

Additional Background Details

Behavior Cloning

Given a corpus D\mathcal{D} of (context, target) pairs, behavior cloning is performed via supervised fine-tuning, which minimizes the teacher-forced cross-entropy [23],

LBC(θ)=−E(x,y)∼D1∣y∣∑i=1∣y∣log⁡πθ(yi∣x,y<i).(6)\mathcal{L}_{\mathrm{BC}}(\theta) = -\mathbb{E}_{(x,y)\sim\mathcal{D}} \frac{1}{\lvert y\rvert}\sum_{i=1}^{\lvert y\rvert}\log\pi_\theta(y_i\mid x,y_{<i}). \tag*{(6)}

Behavior cloning is typically performed on the action tokens. However, the TimeWarp version [13] uses the full response, including the reasoning traces, and is the default type of behavior cloning in our experiments. We note that in Eq. (6), every target token carries the same weight 1/∣y∣1/\lvert y\rvert, whether it belongs to the executed action or to filler thinking tokens. The state distribution is the teacher’s, not the student’s. At deployment, the policy conditions on its own generations and observations, and errors compound, which is the classic distribution-shift argument of imitation learning, under which a per-step error rate ε\varepsilon can inflate to O(εT2)O(\varepsilon T^2) cost over a TT-step horizon unless supervision is collected on the student’s own state distribution [27].

Knowledge Distillation

Distillation replaces gold targets with supervision from a stronger teacher [10]. For autoregressive models, the token-level form matches full next-token distributions along a sequence,

LKD(θ)=ExEy∑iDKL(pT(⋅∣x,y<i)∥πθ(⋅∣x,y<i)),(7)\mathcal{L}_{\mathrm{KD}}(\theta) = \mathbb{E}_{x}\mathbb{E}_{y}\sum_i D_{\mathrm{KL}}\left(p_T(\cdot\mid x,y_{<i})\mathbin{\|}\pi_\theta(\cdot\mid x,y_{<i})\right), \tag*{(7)}

where the choice of the sequence yy (teacher-generated, gold, or student-generated) and of the divergence defines the family. Sequence-level KD [16] sidesteps the inner distributions entirely and applies Eq. (6) to teacher-generated text. On-policy distillation evaluates the divergence at prefixes the student samples, correcting the train–inference mismatch [1].

Black-box Constraint

Every token-level instantiation of Eq. (7) needs two things from the teacher: its full next-token distribution pT(⋅∣⋅)p_T(\cdot\mid\cdot), and a shared tokenizer. The strongest available teachers for web agents are black-box models that usually provide neither. The distillation channel is therefore only textual: the teacher writes, and the student trains on the writing via Eq. (6). But text entangles two signals, (a) the teacher’s decisions (which element to click, what to answer) and (b) its surface distribution (style, phrasing, tone). Training a small student on off-policy frontier text imports both at once, and the student pays a significant perplexity premium on the teacher’s style (Figure 2).

Scratchpad Memory

The scratchpad belongs to the harness state, not to the environment. It is the sequence of memory components (y1memory,…,yt−1memoryy_1^{\mathrm{memory}},\ldots,y_{t-1}^{\mathrm{memory}}) the agent has emitted so far, carried inside the response history y1:t−1y_{1:t-1} that the harness places in every context hth_t (§ 3.1). The agent interacts with it only through the memory tokens. It writes by emitting ytmemoryy_t^{\mathrm{memory}} and reads only what the harness surfaces back at later steps. Under truncated history, a fact from a page the agent has since left survives only if it was written into a rationale component, most durably into the scratchpad memory.

Extended Problem Formulation

Details deferred from the Background’s POMDP formulation ⟨S,A,O,T,T0,O,R⟩\langle S, \mathcal{A}, \mathcal{O}, \mathcal{T}, \mathcal{T}_0, \mathcal{O}, R\rangle [14].

Observation modalities. The observation function O:S→O\mathcal{O}: S \to\mathcal{O} may render the browser state as raw HTML, a set-of-marks screenshot [36], or an accessibility tree. We use the AXTree throughout, a textual serialization of the rendered page, annotated with the element identifiers the action space refers to.

Action space. A\mathcal{A} is a subset of BrowserGym’s browser-level action space (de Chezelles et al., 2025): page interactions (e.g. click, fill), navigation (e.g. goto), tab operations (e.g. tab_focus), and user interaction (send_msg_to_user, which is also how the agent submits its answer). The generated action is deterministically parsed from the action component of the response and passed to the browser for execution. The transition T:S×A→S\mathcal{T}: S \times\mathcal{A} \to S is treated as deterministic.

Initial states and episodes. T0\mathcal{T}_0 draws the initial state uniformly over the benchmark’s tasks. An episode ends when the agent messages the user or exhausts its step budget, at which point the LLM-judge evaluator [41] assigns the terminal R∈{0,1}R \in\{0,1\} against the task specification.

Environment versions. The environment comes in multiple versions {E1,…,En}\{\mathcal{E}_1,\ldots,\mathcal{E}_n\}, the same sites captured at different points in time, each defining its own instance of the POMDP tuple. Training and evaluation fix one version, except when cross-version transfer is itself under test.

Methodology Details

Teacher Details

Teacher-as-agent. The teacher is prompted with the same rendered system and user prompt the student saw: identical goal, AXTree serialization, history format, and action-space description. This keeps the teacher’s output in-distribution as an SFT target rather than free-form advice, and makes the edit a drop-in replacement for the student’s own response. The teacher receives no privileged input in our method: no gold walkthrough, no hints.

Localization. The teacher makes one call per failed episode over the full logged trajectory. The instruction reads:

The agent’s trajectory above FAILED. Identify the FIRST
erroneous step -- the earliest step whose action set the
trajectory on the path to failure.  Reply with ONLY the
integer step index (0-based).  Nothing else.

Section contract. Every edit query ends with a format contract requiring exactly the five tags <think>, <plan>, <step>, <memory>, <action>: think-aloud reasoning grounded only in what is visible in the observation, the running multi-step plan, a single integer in <step> naming the plan step the action belongs to, facts worth carrying forward in <memory>, and exactly one executable action. The contract exists because the student is trained and evaluated with the thinking, planning, and memory components enabled. A teacher that omits one of these components would silently teach the student to drop the field.

Style block. The K=3K=3 exemplars are appended after the contract, at the very end of the query. The contract is the instruction whose loss is most expensive (a missing tag costs the whole step), so it must not be pushed out of the recency window, whereas a style hint that is only partly followed

Require: base model πθ0\pi_{\theta_0}, black-box teacher πT\pi_T (text only), training tasks, exemplar count KK, grounding threshold ρmin⁡\rho_{\min}, weight floor ϕ\phi, dead zone τdz\tau_{\mathrm{dz}}, anchor strength β\beta

Ensure: πθWD\pi_{\theta_{\mathrm{WD}}}

1: P1 (seed): πθBC←\pi_{\theta_{\mathrm{BC}}} \leftarrow fine-tune πθ0\pi_{\theta_0} on successful teacher rollouts DT\mathcal{D}_T with LBC\mathcal{L}_{\mathrm{BC}} (Eq. 6); freeze 2: P2 (rollout): run πθBC\pi_{\theta_{\mathrm{BC}}} on every training task; split episodes into failures Df(BC)\mathcal{D}_f^{(\mathrm{BC})} and style pool Ds(BC)\mathcal{D}_s^{(\mathrm{BC})} 3: D←∅\mathcal{D} \leftarrow\varnothing 4: for all τ=(h1,y1,…,hT,yT)∈Df(BC)\tau= (h_1, y_1, \ldots, h_T, y_T) \in\mathcal{D}_f^{(\mathrm{BC})} do 5: P3 (localize): t′←Loc⁡(τ)t^{\prime} \leftarrow\operatorname{Loc}(\tau), the earliest erroneous step (estimate of t⋆t^\star, Eq. 8) 6: Replay: D←D∪{(hk,yk)}\mathcal{D} \leftarrow\mathcal{D} \cup\{(h_k, y_k)\} for k=1,…,t′−1k = 1, \ldots, t^{\prime} - 1 7: P4 (edit): yk∗∼πT(⋅∣hk,Ds(BC))y_k^\ast\sim\pi_T(\cdot\mid h_k, \mathcal{D}_s^{(\mathrm{BC})}) with KK style exemplars, unexecuted (Eq. 3), for k=t′,…,Tk = t^{\prime}, \ldots, T 8: Filter: D←D∪{(hk,yk∗):ρk≥ρmin⁡}\mathcal{D} \leftarrow\mathcal{D} \cup\{(h_k, y_k^\ast) : \rho_k \ge\rho_{\min}\} 9: end for 10: Weights: for each edited (hk,yk∗)∈D(h_k, y_k^\ast) \in\mathcal{D}, score segments by Δs\Delta_s under πθBC\pi_{\theta_{\mathrm{BC}}} (Eq. 4), rank-map to vs∈[ϕ,1]v_s \in[\phi, 1] (Eq. 10), spread to token weights wiw_i (Eq. 12); pin ⟨A⟩,⟨S⟩\langle A\rangle,\langle S\rangle tokens at wi=1w_i = 1; replayed records keep uniform weights 11: Mask: γi←1\gamma_i \leftarrow1 on ⟨T⟩,⟨P⟩,⟨M⟩\langle T\rangle,\langle P\rangle,\langle M\rangle tokens; γi←10−6\gamma_i \leftarrow10^{-6} on ⟨A⟩,⟨S⟩\langle A\rangle,\langle S\rangle tokens (Appendix B.6) 12: Train: πθWD←arg⁡min⁡θLWD\pi_{\theta_{\mathrm{WD}}} \leftarrow\arg\min_\theta\mathcal{L}_{\mathrm{WD}} (Eq. 5) over D\mathcal{D}, initialized at πθBC\pi_{\theta_{\mathrm{BC}}} with anchor πref=πθBC\pi_{\mathrm{ref}} = \pi_{\theta_{\mathrm{BC}}} 13: return πθWD\pi_{\theta_{\mathrm{WD}}}

Algorithm 1 WEBKD: black-box distillation through grounded teacher edits

still leaves a usable record. Exemplar selection is deterministic given the task. Solved episodes are preferred, the task being edited is excluded, and at most one exemplar is drawn per source task. Exemplars carry the rationale components and the step index but never <action>.

Correction prompt. The correction query is assembled as the student’s rendered context, then the section contract, then the style block. The style block opens with the following instruction:

[STYLE -- write this step in the student agent’s own style] The five sections you emit become training data for the agent whose steps appear above. Match ITS writing style: same register, same typical length, same amount of detail, the same way of phrasing a plan and of noting a memory. Below are verbatim examples of how THIS agent writes. Copy the STYLE only. Do NOT copy their content, their decisions, or their conclusions -- they are unrelated steps from other tasks. Your decision for this step must remain exactly the one you would have made without these examples; only the wording changes.

It is followed by the KK exemplars, each delimited by how the student writes, example nn and end example nn. The correction call is made once per step k≥t′k \ge t^{\prime}, teacher-forced on the student’s original prefix.

P3 Failure Localization Details

Definition 2 (Recoverability). For a trajectory τ\tau, let νt∈{0,1}\nu_t \in\{0,1\} indicate that, from the underlying browser state reached after the first tt actions of τ\tau, some action sequence within the remaining step budget T−tT-t ends with R=1R=1.

Proposition 1 (Every failed web trajectory has a unique first fatal step). Assume the harness of §3.1: a finite step budget TT, deterministic transitions and parsing, a terminal binary reward, and a task solvable from its initial state (ν0=1\nu_0 = 1). Then along any failed trajectory νt\nu_t is non-increasing and equals 00 at the episode’s end, so

t⋆=min⁡{t≥1:νt=0}(8)t^\star= \min\{t \ge1 : \nu_t = 0\} \tag*{(8)}

exists and is unique: every step before t⋆t^\star leaves the task solvable, every step from t⋆t^\star on leaves it unsolvable, and at step t⋆t^\star a recoverability-preserving action existed but was not taken. (Proof and discussion in § F.1.)

The two ways t′t^\prime can miss t⋆t^\star have very different costs. If the teacher localizes too early (t′<t⋆t^\prime< t^\star), it rewrites steps from which the task was still solvable. The state at t′t^\prime is still recoverable, so the only cost is extra edits to the corpus. If it localizes too late (t′>t⋆t^\prime> t^\star), the replayed prefix includes, and so endorses, the fatal steps, and by Proposition 1 no continuation from ht′h_{t^\prime} can succeed. This asymmetry is why the localization prompt asks for the earliest erroneous step (§B.1), and it shows up again as the one-sided error εloc\varepsilon_{\mathrm{loc}} in the guarantee of §E.2.

Localization Accuracy. We sample 200 failed episodes from the rollout pools of the three students. Two human annotators, blind to the teacher’s prediction and to each other, independently mark the earliest step after which success within the remaining budget became impossible, following the same recoverability instruction given to the teacher. Under the strict budget reading, a step counts as unrecoverable only when the remaining budget is insufficient to complete the task. Here, the teacher is never late. It is early on 93% of episodes and exact on the remaining 7%. Under the loop-onset reading, the failure point is the step at which the agent enters a loop that it never escapes. Here the teacher is early on about two-thirds of episodes, exact on about a quarter, and late on roughly 10%. Under both readings, its errors fall mostly on the early side, which is the benign direction. The budget reading is the t⋆t^\star of Proposition 1, so its late rate is the εloc\varepsilon_{\mathrm{loc}} of Theorem 1.

P4 Teacher Edit Details

(i) Style conditioning. The teacher’s query ends with a style block containing K=3K=3 verbatim exemplars of the student’s own writing. The exemplars are mined from the style pool Ds(BC)D_s^{(\mathrm{BC})}, excluding the task being edited, and are selected deterministically per task, with at most one exemplar per source task. The block opens with an explicit instruction to match this agent’s register, typical length, and level of detail, and to copy only the style, keeping the decision “exactly the one you would have made without these examples, but only the wording changes” (Appendix B.1). Exemplars include the student’s rationale components but never its ⟨A⟩\langle A\rangle component: an action is a decision, and the style block should transfer the student’s style, not its decisions. This directly targets the perplexity premium of §3.2. Apart from the correction itself, the corrected trajectory should read as low-surprise text to the student.

(ii) Edits are never executed. The environment always steps on the student’s original action. An edit at step kk therefore leaves the observation at step k+1k+1 unchanged, corrections never compound, and every hkh_k in the corpus is a state the student actually reached. Each teacher call conditions on the student’s original prefix, never on an earlier edit. This mirrors the central idea of on-policy distillation, where the supervising distribution is evaluated on prefixes that the student itself produced [1, 40].

WebKD Loss Details

Remark 1 (Δs\Delta_s as a conditional pointwise mutual information). Writing c=(h,y<a⋆∖s)c=(h,y^\star_{<a}\setminus s) for the context with ss deleted,

Δs=log⁡PπθBC(⟨A⋆⟩∣s,c)PπθBC(⟨A⋆⟩∣c)=PMI⁡πθBC(⟨A⋆⟩;s∣c),(9)\Delta_s = \log\frac{P_{\pi_{\theta_{\mathrm{BC}}}}(\langle A^\star\rangle\mid s,c)}{P_{\pi_{\theta_{\mathrm{BC}}}}(\langle A^\star\rangle\mid c)} = \operatorname{PMI}_{\pi_{\theta_{\mathrm{BC}}}}(\langle A^\star\rangle;s\mid c), \tag*{(9)}

which reads as the pointwise mutual information, under the student’s own distribution, between the segment and the decision it precedes. The first equality is exact. The second takes the student’s probability given the shortened prefix as the reference P(⟨A⋆⟩∣c)P(\langle A^\star\rangle\mid c), and deleting ss is not marginalizing over it, so it is an interpretation of the log-ratio rather than an identity. Negative Δs\Delta_s is meaningful as it marks segments whose presence makes the student less certain of the correct decision, which is why such segments stay in the ranking and are never masked.

We use ranks rather than raw magnitudes by default. Because log⁡P(⟨A⋆⟩)\log P(\langle A^\star\rangle) varies by two orders of magnitude across steps, a magnitude-based weighting would implicitly weight segments by action length. Ranking within each step removes this dependence on scale. Span weights vsv_s become token weights wi∈[ϕ,1]w_i \in[\phi,1] by character-coverage average, so a token straddling a segment boundary receives the area-weighted blend (Eq. (12), Appendix § 7.§ 5).

Scoring policy and the complete map. Segments are sentences or lines of the ⟨T⟩\langle T\rangle, ⟨P⟩\langle P\rangle, and ⟨M⟩\langle M\rangle components. ⟨S⟩\langle S\rangle and ⟨A⟩\langle A\rangle are never segmented, and the merge rules and caps are given in Appendix § 7.§ 5. Both terms of Eq. (4) are scored once, offline, under the frozen seed checkpoint πθBC\pi_{\theta_{\mathrm{BC}}}, the same policy that provides the initialization and, in § 3.3.2, the anchor, so the weights describe the student the training starts from. We write rs∈[0,1]r_s \in[0,1] for the normalized average rank of Δs\Delta_s within its step (ties share their mean rank), σ=max⁡sΔs−min⁡sΔs\sigma= \max_s \Delta_s-\min_s \Delta_s for the within-step spread in nats, and τdz>0\tau_{\mathrm{dz}}>0 for the dead-zone width. Then

vs=clip⁡[ϕ,1](ϕ+(1−ϕ)(12+(rs−12)min⁡(1,στdz))),(10)v_s = \operatorname{clip}_{[\phi,1]}\left(\phi+ (1-\phi)\left(\frac{1}{2}+\left(r_s-\frac{1}{2}\right)\min\left(1,\frac{\sigma}{\tau_{\mathrm{dz}}}\right)\right)\right), \tag*{(10)}

where τdz=0.05\tau_{\mathrm{dz}}=0.05 nats. So a step whose segments are statistically indistinguishable (σ≪τdz\sigma\ll\tau_{\mathrm{dz}}) degrades to the midpoint weight (1+ϕ)/2(1+\phi)/2 on every segment (exactly so at σ=0\sigma=0; within (1−ϕ)σ/(2τdz)(1-\phi)\sigma/(2\tau_{\mathrm{dz}}) of it otherwise), which is the mean span weight of every ranked steps, since average ranks normalized to [0,1][0,1] have mean 1/21/2. A single-segment step has σ=0\sigma=0 and lands at the same midpoint. The imitation term of the objective is a weighted mean of per-token cross-entropies,

LSW=∑i∈Twi CEi∑i∈Twi,(11)\mathcal{L}_{\mathrm{SW}}=\frac{\sum_{i\in T}w_i\,\mathrm{CE}_i}{\sum_{i\in T}w_i}, \tag*{(11)}

where TT indexes the supervised response tokens and CEi=−log⁡πθ(yi∗∣h,y<i∗)\mathrm{CE}_i=-\log\pi_\theta(y_i^* \mid h,y_{<i}^*) is the cross-entropy of corpus token ii. The denominator is the weight sum, never the token count. This matters because it makes wi≡cw_i\equiv c reproduce standard SFT (the per-token mean over the same tokens) exactly for any c>0c>0, so a scheme whose weights average wˉ\bar{w} does not silently train at an effective learning rate of wˉ⋅η\bar{w}\cdot\eta, for learning rate η\eta.

Remark 2 (The update resamples tokens rather than rescaling the loss). Since qw(i)=wi/∑jwjq_w(i)=w_i/\sum_j w_j is a probability distribution over supervised positions, LSW=Ei∼qw[CEi]\mathcal{L}_{\mathrm{SW}}=\mathbb{E}_{i\sim q_w}[\mathrm{CE}_i], so gradient descent on Eq. (11) is gradient descent on ordinary SFT over a corpus in which tokens are resampled in proportion to their weights.

Action-Informative Weighting: Constants and Scoring Interface

Segmentation. Boundaries are newlines, or whitespace following sentence-final punctuation (. ! ? ; :). Each separator stays with the preceding segment, so segments exactly partition each component’s inner span. Segments shorter than 24 non-whitespace characters are merged into the previous segment (into the next, if first). A step is capped at 24 segments by repeatedly merging the shortest adjacent pair. Merges never cross a component boundary.

Scoring interface. Both terms of Eq. (4) are computed by teacher-forced echo-scoring against a served copy of the seed checkpoint: the full (context, target) string is submitted with the prompt echoed and per-token log-probabilities returned, at temperature zero and with no new tokens generated. The log-probability of ⟨A∗⟩\langle A^*\rangle is the sum over its token positions. The ablated variant deletes the segment’s characters (including its trailing separator) and re-tokenizes. Numbered plan lines are deliberately not renumbered after a deletion. Renumbering would perturb segments other than the ablated one and break the leave-one-out contract. The chat template’s pre-opened <think> tag is stripped before the target is appended, so the scored string matches the training-time rendering.

Characters to tokens. With chars⁡(i)\operatorname{chars}(i) the character span of token ii under the tokenizer’s offset mapping, the token weight is the coverage-weighted average

wi=∑s∣chars⁡(i)∩s∣⋅vs+∣chars⁡(i)∖⋃ss∣⋅1∣chars⁡(i)∣,(12)w_i=\frac{\sum_s\left|\operatorname{chars}(i)\cap s\right|\cdot v_s+\left|\operatorname{chars}(i)\setminus\bigcup_s s\right|\cdot1}{\left|\operatorname{chars}(i)\right|}, \tag*{(12)}

clamped to [ϕ,1][\phi,1]. Characters outside every rationale segment (tags, separators, and the components pinned at weight 1) contribute weight 1, zero-width special tokens take weight 1, and the response envelope (the template’s closing tokens) is never down-weighted.

Anchor Implementation

Estimator. k3k_3 in Eq. (5) is the “k3k_3” estimator [28]: it is non-negative and low-variance, and unbiased for DKL(πθ∥πref)D_{\mathrm{KL}}(\pi_\theta\Vert\pi_{\mathrm{ref}}) under sampling from πθ\pi_\theta. The log-ratio did_i is clamped to [−20,8][-20, 8]. The asymmetry is deliberate. di≈0d_i \approx0 at initialization and drifts negative as the student fits the corpus, where k3k_3 grows only linearly and is harmless. The positive tail is the direction in which ede^{d} can overflow 16-bit precision, and it is not the direction the penalty exists to control.

Reference pass. πref\pi_{\mathrm{ref}} is the frozen seed checkpoint, held in 16-bit precision and evaluated in a second, gradient-free forward pass per micro-batch. Per-token log-probabilities are gathered with a fused cross-entropy rather than a full log-softmax, avoiding a ∣y∣×∣V∣|y| \times|V| 32-bit intermediate. The anchor’s marginal memory cost is nonetheless substantial, an unsharded 16-bit copy of the reference policy on every rank (measured ≈27\approx27 GB at 9B scale) on top of the loss computation’s 32-bit logit upcast, which is why training runs single-rank with ZeRO-3 parameter partitioning and CPU-offloaded optimizer state (Appendix § 8.§ 3).

Why normalize by ∑iγi\sum_i \gamma_i. In our corpus, the rationale mask anchors roughly 88% of supervised characters, while an action mask would anchor roughly 9%. Normalized by token count instead, the same β\beta would be an order of magnitude weaker under the action mask because actions are short.

Additional Experimental Details

Benchmark Baselines

We describe each baseline of Table 1 and Figure 4 below.

  1. Zero-Shot: The base model without fine-tuning.

  2. Behavior Cloning (BC): The base model is trained using supervised fine-tuning (Eq. (6)) on the teacher rollouts containing the observation history, prompts, and actions only.

  3. Behavior Cloning (TW): The TimeWarp version of behavior cloning [13]. It is identical to vanilla BC, except that it also includes the thinking, planning, step, and memory tokens during behavior cloning.

  4. m-GRPO: Multi-turn Group Relative Policy Optimization (m-GRPO) is an outcome-based RL baseline, which uses the trajectory’s reward for credit assignment [33].

  5. Self/Student Edit: An edit-style baseline in which the student, instead of an external teacher model, edits its own failed trajectories.

  6. Off-policy Takeover: An edit-style baseline where, instead of the teacher editing the student’s failed trajectories, the teacher takes over from the point of failure and completes the trajectory. The student is then trained off-policy on the edited trajectories. This is similar to on-policy expert correction [18].

  7. Student Re-style Edit: A two-pass edit, in which the teacher first edits the student’s failed trajectories, and the student is then prompted to rewrite the edits in its own style. The student is then trained on-policy on the re-styled edits.

Loss Ablation Baselines

Each variant keeps the weighted objective of Eq. (11) and changes only the token weights wi∈[ϕ,1]w_i \in[\phi,1]. The ⟨A⟩\langle\mathrm{A}\rangle and ⟨S⟩\langle\mathrm{S}\rangle tokens stay at wi=1w_i = 1 in every variant. Span weights wsw_s become token weights wiw_i by the same character-coverage average as in WebKD. The “w/ KL” column of Table 3 adds the anchor of Eq. (5) unchanged.

  1. LCE\mathcal{L}_{\mathrm{CE}} (uniform). Standard SFT cross-entropy with equal weight on every response token, the control for all weighted variants.

  2. LGND\mathcal{L}_{\mathrm{GND}} (grounding). A soft, within-step version of the grounding filter of Algorithm 1, which floors any rationale span that makes a claim not supported by the goal or by the AxTrees

observed up to step kk. The claims C(s)C(s) of a span are its quoted strings, numbers, element identifiers, and capitalized entities, and a claim is grounded if its case- and whitespace-folded form occurs in the goal or in one of those AXTrees,

vs={ϕif some c∈C(s) is not grounded,1otherwise.(13)v_s = \begin{cases} \phi& \text{if some } c \in C(s) \text{ is not grounded},\\ 1 & \text{otherwise.} \end{cases} \tag*{(13)}
  1. LCONS\mathcal{L}_{\mathrm{CONS}} (teacher self-consistency). A span is weighted by how much of it the teacher reproduces when it re-edits the same step k=3k = 3 times, net of the overlap expected by chance,

vs=ϕ+(1−ϕ)clip⁡[0,1](csame(s)−cnull(s)1−cnull(s)),(14)v_s = \phi+ (1-\phi)\operatorname{clip}_{[0,1]}\left(\frac{c_{\mathrm{same}}(s)-c_{\mathrm{null}}(s)}{1-c_{\mathrm{null}}(s)}\right), \tag*{(14)}

where csame(s)c_{\mathrm{same}}(s) is the IDF-weighted containment of ss in the teacher’s resampled edits of the same step and cnull(s)c_{\mathrm{null}}(s) is the same statistic against resampled edits of steps from other tasks.

  1. LPPL\mathcal{L}_{\mathrm{PPL}} (student perplexity). Each token is weighted by how likely the seed student already finds it, so the high-perplexity tokens of the teacher’s edit are floored,

wi=ϕ+(1−ϕ)ri,(15)w_i = \phi+ (1-\phi)r_i, \tag*{(15)}

where ri∈[0,1]r_i \in[0,1] is the normalized average rank of log⁡πθBC(yi∗∣⋅)\log\pi_{\theta_{\mathrm{BC}}}(y_i^* \mid\cdot) among the rationale tokens of its step.

Training Configuration

Corpus. The corpus records are step-level: one (context, response) pair per step, the context being the full rendered agent state (goal, AXTree, history) and the response the five-component output. On the corpus used throughout, 15 failed training episodes yield 432 step records. The teacher edits 403 of them (the remaining 29 precede t′t' and are replayed), the grounding filter of Algorithm 1 removes 40 edited steps (9.9%), and 392 records survive (363 edited, 29 replayed). The edited targets total ≈\approx64k response tokens (16.6k think, 19.3k plan, 8.7k memory, 5.2k action, 13.8k structural). Rollouts (P2) use temperature 0.01 and a 30-step budget, with the thinking, plan, and memory components enabled and no hints, the same interface as evaluation. Training is full-parameter fine-tuning from the seed checkpoint with the hyperparameters of Table 4.

HyperparameterValue
fine-tuningfull-parameter, from the seed checkpoint
learning rate1×10−51 \times10^{-5}, cosine decay, warmup ratio 0.1
epochs2
context cutoff20,480 tokens
batch1 per device ×\times 16-step gradient accumulation (effective 16)
precisionbf16, gradient checkpointing
partitioningZeRO-3 with CPU offload
CE weight floor ϕ\phi0.1
dead zone τdz\tau_{\mathrm{dz}}0.05 nats
anchor strength β\beta0.03 (per anchored token)
anchor mask γ\gamma1 on think/plan/memory, 10−610^{-6} elsewhere

Table 4. Training hyperparameters for the combined objective.

Compute. Each fine-tune runs on a single H200 GPU with ZeRO-3 parameter partitioning and CPU-offloaded optimizer state. Corpus generation and evaluation parallelize over a farm of single-GPU workers, one containerized browser environment per GPU, and all teacher and judge calls go through hosted APIs.

Cost and latency. Most of the teacher cost is in P1, which makes 4,448 calls and uses 21.8 M prompt tokens to produce the demonstrations. The correction stage is much cheaper. P3 makes one call per failed episode (15 calls, 0.47M tokens), and P4 makes one call per edited step (403 calls, 4.0 M tokens, 6% of which is the style block). Correction is therefore 17% of the pipeline’s 26.3 M prompt tokens, paid once, or about the cost of 135 teacher episodes at the teacher’s in-harness rate of 33k prompt tokens per episode. These counts are lower bounds, since the prompts of 13% of the P1 conversations were not kept and hidden reasoning tokens were not logged (0.78 M visible completion tokens). A fine-tune takes 1.0 GPU-hour on one H200, and evaluating the 103 v6 tasks takes 20 minutes on one 48 GB L40S. Measured inside the harness, the trained 4B student takes a median of 6.10 s per step (38.8 s per episode), against 9.05 s per step for the seed and 12.80 s per step (68.1 s per episode) for the teacher acting as the agent.

Additional Experimental Results

Can we simply train behavior cloning for longer?

We fine-tune Qwen-3.5 9B using the TimeWarp version of Behavior Cloning (BC) for longer epochs, and compare it against the standard setting of WEBKD where we fine-tune from the BC seed. Figure 7 shows the success rate of these two baselines for the Qwen-3.5 9B model. BC alone plateaus early, remaining between 0.24 and 0.26 regardless of the training budget. This suggests that additional epochs on the same training data alone provide little benefit. In contrast, adding WEBKD results in consistent gains at every budget beyond the one-epoch BC seed. The best checkpoint is when WEBKD is trained for two additional epochs.

Success rate of behavior cloning and BC+WebKD over total epochs

Figure 7. Behavior cloning over more epochs doesn’t improve the success rate, as it flattens at ∼\sim 25%, whereas WEBKD continues to improve and peaks at the 3rd total epoch for the Qwen-3.5 9B model. WEBKD is trained from the first epoch of the BC seed.

Error Analysis

Figure 8 assigns every evaluation trajectory to a single outcome, which separates navigation failures (the agent never reaches the page containing the answer) from failures that occur after the relevant page has been found. The zero-shot model almost never completes a task. ∼\sim 97% of its trajectories end by it getting stuck in a loop. Behavior Cloning (BC) substantially reduces looping but leaves it as the dominant failure mode (∼\sim 62.5%). Behavior Cloning (TW) and m-GRPO both reach roughly 30% success, yet each still loses 15.5% – 19.4% trajectories to loops. Off-policy takeover produces the fewest unsupported answers among the methods (27). However, it also has the highest looping failure rate (36.6%) among the non-BC methods.

Figure 8. Failure mode analysis of Qwen3.5-4B. Each bar assigns every evaluation trajectory of a method to exactly one outcome for the 103×3=309103 \times3 = 309 tasks.

WEBKD passes the most tasks while getting stuck in a loop less than any other method (∼\sim 8.7%). Most of the gain comes from navigation. Counting trajectories that either pass or end in right page, wrong answer, WEBKD reaches the correct page 202 times, while no baseline does so more than 143 times. Because of this, its remaining errors move downstream, and right page, wrong answer becomes its largest failure category (∼\sim 24.3%). This suggests that further improvements are more likely to come from better answer extraction once the relevant page is found than from better navigation. Task and judge defects remain roughly constant across methods (8–12 trajectories where labeled), indicating a small noise floor in the evaluation that does not depend on the agent.

Where do the gains come from?

Figure 9 breaks the overall improvement down by task type. Gains are positive in all five categories, but their size varies considerably. Placing an order improves the most, rising from 0% to 25.9% (+25.9 pp), and it is the only category where performance started at zero. Counting/listing (+9.5 pp, from 11.9% to 21.4%) and lookup (+8.7 pp) show moderate gains, while multi-hop (+5.7 pp) and verification (+4.8 pp) improve the least. Because each category has only 9–29 examples, these differences should be read with caution: only the gains on placing an order and counting/listing have 95% confidence intervals that exclude zero.

Absolute gain by task type bar chart

Figure 9. Absolute gain by task type, in percentage points.

A Complete Worked Example

This subsection gives the unabridged text of the step shown in Figure 3.

Edits for the same student step

Figure 3. Edits for the same student step. The raw teacher edit replaces the student’s action but rewrites the plan in its own style. The style-conditioned edit keeps the student’s nested plan format. Values in brackets give the span weight vsv_s. ⟨T⟩\langle\mathrm{T}\rangle: think, ⟨P⟩\langle\mathrm{P}\rangle: plan, ⟨M⟩\langle\mathrm{M}\rangle: memory, ⟨A⟩\langle\mathrm{A}\rangle: action.

Student, step 5.

<think> We successfully purchased the Welch’s item and are
on the thank-you page showing code B644DDC66C. Next, we need
to search for the Mojito mix. I will click the search box
(bid "15") to bring up the search input. </think>
<plan> 1. Search for Mojito mix - Click search box -
Type query - Press Enter 2. Open first result and
buy - Click first result link - Click Buy Now and note
confirmation code 3. Search for Italian Basil Pesto
[...] 5. Send all confirmation codes to the user </plan>
<step> 2 </step>

<memory> I am clicking the search box to prepare for ordering the Mojito mix. </memory>

<action> click(’15’) </action>

Raw teacher edit.

<think> The page shows the order confirmation for Welch’s Orange Pineapple Juice with code B644DDC66C. I need now search for the second product, so I will navigate back to the shop home page within the allowed SHOP environment. </think>

<plan> 1. Record Welch’s confirmation code. 2. Navigate to shop home/search page. 3. Search for Stirrings Simple Classic Cocktail Mix Mojito. 4. Open matching product, buy it, and record confirmation code. 5. Navigate to shop home/search page. 6. Search for Italian Basil Pesto. 7. Open matching product, buy it, and record confirmation code. 8. Send all confirmation codes to the user. </plan>

<step> 2 </step>

<memory> Welch’s Orange Pineapple Juice confirmation code: B644DDC66C. </memory>

<action> goto(’http://localhost:5002/abc’) </action>

Style-conditioned teacher edit (the WEBKD target), with span weights vsv_s in brackets.

<think> [0.10] The purchase confirmation page for Welch’s Orange Pineapple Juice is displayed, and the code shown is B644DDC66C. [0.90] I need to continue shopping for the next product, so I will return to the shop search page. </think>

<plan> [0.80] 1. Record Welch’s confirmation code [0.40] 2. Search for Stirrings Simple Classic Cocktail Mix Mojito – Go to shop page – Type query and press Enter – Open matching result [1.00] – Click Buy Now and record code [0.70] 3. Search for Italian Basil Pesto – Go to shop page – Type query and press Enter – Open matching result [0.60] – Click Buy Now and record code [0.50] 4. Send all confirmation codes to the user </plan>

<step> 2 </step>

<memory> [0.30] Welch’s Orange Pineapple Juice confirmation code is B644DDC66C. [0.20] Next I need to search for Stirrings Simple Classic Cocktail Mix Mojito. </memory>

<action> goto(’http://localhost:5002/abc’) </action>

Theoretical Intuition and Analysis

What the Anchored Update Does

Write pi=πθ(yi∗∣⋅)p_i = \pi_\theta(y_i^* \mid\cdot) and qi=πref(yi∗∣⋅)q_i = \pi_{\mathrm{ref}}(y_i^* \mid\cdot) for the two policies’ probabilities of corpus token yi∗y_i^*, p(i)p^{(i)} for the student’s full next-token distribution at that position, eyi∗e_{y_i^*} for the one-hot target, and collect the two normalized coefficients acting on token ii: ai=wi/∑jwja_i = w_i/\sum_j w_j (imitation) and bi=βγi/∑jγjb_i = \beta\gamma_i/\sum_j \gamma_j (anchor). Because the pointwise anchor depends on the position-ii logits z(i)z^{(i)} only through log⁡pi\log p_i, the gradient of (5) at that position factorizes exactly:

∇z(i)L=(ai−bi(1−qi/pi))⏟throttle ci⋅(p(i)−eyi∗)⏟SFT direction.(16)\nabla_{z^{(i)}} \mathcal{L} = \underbrace{\left(a_i-b_i\left(1-q_i/p_i\right)\right)}_{\text{throttle }c_i} \cdot \underbrace{\left(p^{(i)}-e_{y_i^*}\right)}_{\text{SFT direction}}. \tag*{(16)}

Eq. 16 says the anchor never rotates the update. Every anchored token still moves along the SFT direction, toward the corpus token while ci>0c_i > 0 and away from it when ci<0c_i < 0, and the anchor only rescales it through the data-dependent scalar coefficient cic_i, which we call the throttle:

  • At initialization the anchor is inert. Training starts from πref\pi_{\mathrm{ref}}, so pi=qip_i=q_i and ci=aic_i=a_i, and the first update is exactly weighted SFT. The penalty acts on drift accumulated during training, never on the starting point.

  • Below the reference, the anchor helps. If interference drives pip_i under qiq_i (the student losing probability on text its prior found natural), then qi/pi>1q_i/p_i>1 and ci>aic_i>a_i, so the anchor adds force toward the corpus token, protecting prior competence rather than fighting the corpus.

  • Above the reference, it throttles and can stop. As pip_i climbs past qiq_i the throttle falls monotonically toward ai−bia_i-b_i. When bi>aib_i>a_i it vanishes at pi=qibi/(bi−ai)p_i=q_i b_i/(b_i-a_i) and is negative beyond it, where the update pushes pip_i back down; that point lies below 1, so the throttle actually stops the token, only when bi(1−qi)>aib_i(1-q_i)>a_i (Corollary 1), which is the content of Proposition 2.

  • On ⟨A⟩\langle A\rangle and ⟨S⟩\langle S\rangle, it is absent. ⟨A⟩\langle A\rangle and ⟨S⟩\langle S\rangle carry γi≈0\gamma_i\approx0, so bi≈0b_i\approx0 and ci≈aic_i\approx a_i throughout, and the teacher’s decision is learned at full strength, all the way to the one-hot target.

Proposition 2 (Per-token target of the anchored objective). Fix a supervised position ii, treat its logits as free parameters, and hold the context fixed. The contribution of position ii to Eq. (5) is minimized at

pi⋆={min⁡{1, qi⋅bibi−ai},bi>ai,1,bi≤ai.(17)p_i^\star= \begin{cases} \min\left\{1,\ q_i\cdot\frac{b_i}{b_i-a_i}\right\}, & b_i>a_i,\\ 1, & b_i\le a_i. \end{cases} \tag*{(17)}

(Proof in Appendix § 11.)

That is, the anchor does not shrink the step toward the corpus. It moves the target, from the one-hot corpus token to a bounded multiple of the reference policy’s own probability.

Corollary 1 (Critical anchor strength). The cap in Eq. (17) exists iff β>βˉi≡(wi/γi)⋅(∑jγj/∑jwj)\beta>\bar{\beta}_i\equiv(w_i/\gamma_i)\cdot(\sum_j\gamma_j/\sum_j w_j). Because βˉi∝wi\bar{\beta}_i\propto w_i, the cap appears first on the spans the action-informative weighting marked as least informative about the action.

The condition β>βˉi\beta>\bar{\beta}_i makes the interior optimum of Eq. (17) finite. That optimum is below 1, and so limits the token, only under the stronger condition qibi/(bi−ai)<1q_i b_i/(b_i-a_i)<1, that is, bi(1−qi)>aib_i(1-q_i)>a_i. In anchor strength this is β>βˉi/(1−qi)\beta>\bar{\beta}_i/(1-q_i), so the order in which caps bind also depends on qiq_i: among tokens with equal qiq_i the least informative spans are capped first, but a span the reference already finds likely can stay uncapped at a β\beta that caps a more informative, less likely one.

A Single-Round Relabeling Bound

The pipeline admits an imitation-learning guarantee in the style of DAgger ([27]), with the classical action oracle replaced by the two calls a black-box teacher actually answers: localize (P3) and correct (P4). Write ρ(π)\rho(\pi) for the success rate of a policy on the task distribution and ρBC\rho_{\mathrm{BC}} for the fraction of tasks whose logged seed rollout (P2) succeeded, an estimate of ρ(πθBC)\rho(\pi_{\theta_{\mathrm{BC}}}). Three error rates describe one correction round, each a population quantity over the sampled failed episodes. εloc=Pr⁡[t′>t⋆]\varepsilon_{\mathrm{loc}}=\Pr[t'>t^\star] is the late-localization rate of P3 (early misses are benign for the guarantee; they only spend edits). εcorr\varepsilon_{\mathrm{corr}} is the teacher’s own failure rate when it takes over as the agent from a still-recoverable localized state ht′h_{t'} and plays the episode out. εˉ\bar{\varepsilon} is the trained student’s per-step disagreement, over the full structured response, with the relabeled process that replays the seed through step t′−1t'-1 and then follows the teacher, measured on that process’s own history distribution, that is, εˉ=1T∑t′=1Tδt\bar{\varepsilon}=\frac{1}{T}\sum_{t'=1}^{T}\delta_t (formal definitions in Appendix § 11.§ 3).

Theorem 1 (Single-round relabeling bound, informal). Under the assumptions of Proposition 1, the student πθWD\pi_{\theta_{\mathrm{WD}}} trained on the P1–P4 corpus satisfies

1−ρ(πθWD)≤(1−ρBC)(εloc+εcorr)⏟teacher term+Tεˉ,εˉ≤ρBCεˉret+(1−ρBC)(εˉfit+εˉrec)(18)1-\rho(\pi_{\theta_{\mathrm{WD}}})\le\underbrace{(1-\rho_{\mathrm{BC}})(\varepsilon_{\mathrm{loc}}+\varepsilon_{\mathrm{corr}})}_{\textit{teacher term}}+T\bar{\varepsilon}, \qquad \bar{\varepsilon}\le\rho_{\mathrm{BC}}\bar{\varepsilon}_{\mathrm{ret}}+(1-\rho_{\mathrm{BC}})(\bar{\varepsilon}_{\mathrm{fit}}+\bar{\varepsilon}_{\mathrm{rec}}) \tag*{(18)}

where εˉret\bar{\varepsilon}_{\mathrm{ret}} is disagreement with the seed’s logged responses on episodes the seed already solves (retention), εˉfit\bar{\varepsilon}_{\mathrm{fit}} is disagreement with the relabeled process at the states the corpus supervises (the logged response before t′t', and at t′t' the teacher’s response distribution, of which the corpus record is

one draw), and εrec\varepsilon_{\mathrm{rec}} is disagreement at the post-correction states no corpus record covers. (Formal statement and proof in Appendix § 11.§ 3.)

Eq. (18) separates what the teacher limits from what the student limits. With a perfect student (εˉ=0\bar{\varepsilon}=0), the remaining failure is the fraction of seed failures that the teacher either localizes too late or cannot repair itself. We estimate both error rates on the 15 seed failures the corpus is built from. Taking over at t′t^{\prime}, the teacher solves 14 of them. The one it fails was localized at the first step, a state that is recoverable by assumption, so the failure counts against correction rather than localization, giving εloc=0/15\varepsilon_{\mathrm{loc}}=0/15 and εcorr=1/15\varepsilon_{\mathrm{corr}}=1/15 on this pool. The teacher term is then 0.70×0.07≈0.050.70 \times0.07 \approx0.05, well below the observed student failure rate of 0.61, so the teacher’s errors are not the main limit. This is an estimate rather than a direct measurement of the term, because the takeover failure rate comes from training-split states under one judge and the seed failure rate from the test split under another. For reference, the teacher succeeds on 0.71 of test episodes in the same harness (Table 1).

The student term TεˉT\bar{\varepsilon} is linear in TT because εˉ\bar{\varepsilon} is evaluated on the history distribution of the relabeled process, which the corpus supervises except at the post-correction states counted in εrec\varepsilon_{\mathrm{rec}}. This is where collecting the corpus on the student’s own states enters the bound. The bound concerns terminal failure, whereas the O(T2ε)O(T^{2}\varepsilon) bound for cloning off-policy demonstrations (§A.1) concerns cumulative cost, so the two are not directly comparable. Because the disagreement is measured on the full structured response, any rewording of a rationale counts as disagreement, so TεˉT\bar{\varepsilon} is conservative and can exceed one. We use the bound for its structure, which separates the teacher’s errors from the student’s and places the student’s error on the relabeled process’s own histories, not as a numerical prediction of the student’s failure rate.

Premium Split, Rank Weighting, and the Anchor Budget

This subsection relates the per-token result of Proposition 2 to the premium of Definition 1. Under uniform SFT, the premium determines how the update splits between rationale and action (Proposition 3). The rank map of Eq. (10) orders the update optimally to first order in an additive twin with a common emission probability (Theorem 2). The anchor limits how much premium each token can absorb, and the limit is largest on the spans that the weighting marks as decisive (Corollary 2). Proofs are in Appendix § 11.§ 4.

Where the uniform update goes. Fix a set of corpus steps and score them under the seed πBC∗\pi_{\mathrm{BC}}^{*}, the policy every run starts from. Write Irat\mathcal{I}_{\mathrm{rat}} for the positions of the rationale tokens (⟨T∗⟩\langle T^{*}\rangle, ⟨PBC∗⟩\langle P_{\mathrm{BC}}^{*}\rangle, ⟨M∗⟩\langle M^{*}\rangle) and Iact\mathcal{I}_{\mathrm{act}} for the positions of the action tokens across those steps, with nrat=∣Irat∣n_{\mathrm{rat}}=|\mathcal{I}_{\mathrm{rat}}| and nact=∣Iact∣n_{\mathrm{act}}=|\mathcal{I}_{\mathrm{act}}|. Write PPLrat\mathrm{PPL}_{\mathrm{rat}} and PPLact\mathrm{PPL}_{\mathrm{act}} for the per-token perplexity of Eq. (1) pooled over each set, so that log⁡PPLC=1nC∑i∈ICCEi\log\mathrm{PPL}_{C}=\frac{1}{n_{C}}\sum_{i\in\mathcal{I}_{C}}\mathrm{CE}_{i}, and GC=∑i∈IC∥∇z(i)CEi∥2G_{C}=\sum_{i\in\mathcal{I}_{C}}\|\nabla_{z(i)}\mathrm{CE}_{i}\|_{2} for the logit-gradient mass that uniform SFT places on set CC.

Lemma 1 (Gradient norm is sandwiched by the surprisal). At every supervised position ii, 1−e−CEi≤∥∇z(i)CEi∥2≤2(1−e−CEi)1-e^{-\mathrm{CE}_{i}}\leq\|\nabla_{z(i)}\mathrm{CE}_{i}\|_{2}\leq\sqrt{2(1-e^{-\mathrm{CE}_{i}})}.

Assumption 1 (Bounded surprisal). Every per-token surprisal is bounded, CEi≤Λ\mathrm{CE}_{i}\leq\Lambda for some Λ<∞\Lambda<\infty.

Proposition 3 (The premium fixes the split of the uniform update). (i) Restricted to Irat∪Iact\mathcal{I}_{\mathrm{rat}}\cup\mathcal{I}_{\mathrm{act}}, the share of the token-pooled uniform loss (every supervised token weighted equally, rather than each step normalized by its length as in Eq. (6)) that the action tokens contribute at initialization is exactly

nactlog⁡PPLactnactlog⁡PPLact+nratlog⁡PPLrat.(19)\frac{n_{\mathrm{act}}\log\mathrm{PPL}_{\mathrm{act}}}{n_{\mathrm{act}}\log\mathrm{PPL}_{\mathrm{act}}+n_{\mathrm{rat}}\log\mathrm{PPL}_{\mathrm{rat}}}. \tag*{(19)}

(ii) Under Assumption 1, the action’s share of the logit-gradient mass satisfies

GactGact+Grat≤XX+Y,X=2 nactlog⁡PPLact,Y=1−e−ΛΛ nratlog⁡PPLrat.(20)\frac{G_{\mathrm{act}}}{G_{\mathrm{act}}+G_{\mathrm{rat}}}\leq\frac{X}{X+Y},\qquad X=\sqrt{2}\,n_{\mathrm{act}}\log\mathrm{PPL}_{\mathrm{act}},\qquad Y=\frac{1-e^{-\Lambda}}{\Lambda}\,n_{\mathrm{rat}}\log\mathrm{PPL}_{\mathrm{rat}}. \tag*{(20)}

Why the rank map is the right order. Proposition 3 says how much of the update lands on the rationale. The weighting of §3.3.1 decides how that part is spent across segments. Fix a corpus step with corrected action ⟨A∗⟩\langle A^{*}\rangle and rationale segments s1,…,sns_{1},\ldots,s_{n} (Appendix § 7.§ 5), and write Δj\Delta_{j} for the score of Eq. (4) on segment sjs_{j}.

Assumption 2 (Additive twin). For every subset U⊆{1,…,n}U \subseteq\{1,\ldots,n\} of segments present in the rationale, the student’s log-probability of the corrected action is log⁡Pπ(⟨A∗⟩∣h,U)=α0+∑j∈UΔj\log P_{\pi}(\langle A^{*}\rangle\mid h,U)=\alpha_{0}+\sum_{j\in U}\Delta_{j} for some constant α0\alpha_{0}, so the leave-one-out score of Eq. (4) recovers Δj\Delta_{j} exactly.

Assumption 3 (Independent emission). At deployment the student writes segment sjs_{j} into its own rationale independently with probability κj∈(0,1)\kappa_{j}\in(0,1), and raising log⁡κj\log\kappa_{j} by dud u nats costs dud u nats of premium on that segment (Definition 1).

Theorem 2 (Rank weighting is first-order optimal credit assignment). Under Assumptions 2 and 3, the deployment probability of the corrected action is Pπ(⟨A∗⟩∣h)=eα0∏j=1n(1−κj+κjeΔj)P_{\pi}(\langle A^{*}\rangle\mid h)=e^{\alpha_{0}}\prod_{j=1}^{n}(1-\kappa_{j}+\kappa_{j}e^{\Delta_{j}}), and the gain in log⁡Pπ(⟨A∗⟩∣h)\log P_{\pi}(\langle A^{*}\rangle\mid h) per nat of premium absorbed on segment sjs_{j} is

μj=∂log⁡Pπ(⟨A∗⟩∣h)∂log⁡κj=κj(eΔj−1)1−κj+κjeΔj,(21)\mu_{j}=\frac{\partial\log P_{\pi}(\langle A^{*}\rangle\mid h)}{\partial\log\kappa_{j}}=\frac{\kappa_{j}(e^{\Delta_{j}}-1)}{1-\kappa_{j}+\kappa_{j}e^{\Delta_{j}}}, \tag*{(21)}

which is strictly increasing in Δj\Delta_{j}, zero at Δj=0\Delta_{j}=0, and negative for Δj<0\Delta_{j}<0. If moreover κj=κ\kappa_{j}=\kappa for all segments of the step and a step on LSW\mathcal{L}_{\mathrm{SW}} sheds premium on segment sjs_{j} at a rate proportional to its weight vjv_{j} (Remark 2), then for any fixed multiset of segment weights {v1,…,vn}\{v_{1},\ldots,v_{n}\} the first-order gain ∑jμjvj\sum_{j}\mu_{j}v_{j} is maximized by assigning the weights in the order of Δj\Delta_{j}, and the maximizing assignment depends on the Δj\Delta_{j} only through that order.

Remark 3 (What the twin predicts). The twin makes two predictions. First, segments with Δj<0\Delta_{j}<0 have μj<0\mu_{j}<0, so learning them lowers the deployment probability of the corrected action. The weighting of §B.4 does not mask them: it ranks them below the step’s segments with Δj≥0\Delta_{j}\geq0 and keeps their weights in [ϕ,1][\phi,1]; outside the dead zone a unique lowest-ranked segment reaches ϕ\phi, and 42% of segments fall in this class. The twin predicts that masking them costs nothing and may help. Second, the gain of LWD over LCE in Table 3 should grow with the within-step spread σ\sigma of Δj\Delta_{j}, since a step with σ≈0\sigma\approx0 has nothing to reorder, which is what the dead zone of Eq. (10) already assumes.

The anchor as a premium budget

Proposition 2 gives the per-token target of the anchored objective. Read in the units of Definition 1, it is a budget.

Corollary 2 (Per-token premium budget). Under the anchored objective of Eq. (5), the premium the student can shed on a rationale token ii, its CEi\mathrm{CE}_{i} at initialization minus its CEi\mathrm{CE}_{i} at the per-token optimum pi∗p_{i}^{*} of Eq. (17), satisfies

log⁡pi∗qi≤−log⁡(1−βˉiβ)whenever β>βˉi,βˉi=wiγi⋅∑jγj∑jwj,(22)\log\frac{p_{i}^{*}}{q_{i}}\leq-\log\left(1-\frac{\bar{\beta}_{i}}{\beta}\right)\qquad\text{whenever }\beta>\bar{\beta}_{i},\qquad\bar{\beta}_{i}=\frac{w_{i}}{\gamma_{i}}\cdot\frac{\sum_{j}\gamma_{j}}{\sum_{j}w_{j}}, \tag*{(22)}

with equality when the interior cap qibi/(bi−ai)q_{i}b_{i}/(b_{i}-a_{i}) is at most 1 (when it exceeds 1 the token is fit to pi∗=1p_{i}^{*}=1 and sheds its full CEi\mathrm{CE}_{i}, which is below the right-hand side), and is the full CEi\mathrm{CE}_{i} at initialization (the token may be fit to pi∗=1p_{i}^{*}=1) when β≤βˉi\beta\leq\bar{\beta}_{i}. The budget decreases in β\beta and increases in wiw_{i}, so at a fixed β\beta the spans the weighting marks as decisive receive the largest budget.

Proofs and Theoretical Remarks

The first fatal step: proof of Proposition 1

Fix a task and a failed trajectory τ\tau executed under the harness of §3.1. Write s(t)s_{(t)} for the underlying browser state after the first tt actions of τ\tau, with s(0)s_{(0)} at the initial state, and recall the recoverability indicator vtv_{t} of Definition 2. The assumptions of Proposition 1, stated in full:

Assumption 4 (Finite budget). The harness enforces a step budget TT, and an episode that issues a terminal action earlier enters an absorbing state with its reward fixed.

Assumption 5 (Determinism). TT, O\mathcal{O}, and fparsef_{\mathrm{parse}} are deterministic, so the state reached by a given action sequence from s(0)s_{(0)} is unique and replayable.

Assumption 6 (Terminal binary reward). R∈{0,1}R\in\{0,1\} is assigned once, when the episode ends.

Assumption 7 (Feasibility). v0=1v_{0}=1: the task is solvable from its initial state within the budget.

Lemma 2 (Recoverability is absorbing). Under Assumptions 4–6, vt=0v_{t}=0 implies vt+1=0v_{t+1}=0 along τ\tau.

Proof. Suppose νt+1=1\nu_{t+1}=1: some action sequence (a1′,…,am′)(a'_1,\ldots,a'_m) with m≤T−(t+1)m\le T-(t+1) reaches R=1R=1 from s(t+1)s_{(t+1)}. Since s(t+1)=T(s(t),at+1)s_{(t+1)}=\mathcal{T}(s_{(t)},a_{t+1}) deterministically, the sequence (at+1,a1′,…,am′)(a_{t+1},a'_1,\ldots,a'_m) has length m+1≤T−tm+1\le T-t and reaches R=1R=1 from s(t)s_{(t)}, so νt=1\nu_t=1. The contrapositive gives the claim.

Proof of Proposition 1. ν0=1\nu_0=1 by Assumption 7. At the episode’s end ν=0\nu=0. If the budget is exhausted, the only continuation within budget 0 is the empty one, and it ends with the episode’s own reward R(τ)=0R(\tau)=0. If a terminal action ended the episode early, the state is absorbing with R=0R=0 (Assumption 4). By Lemma 2 the sequence ν0,ν1,…\nu_0,\nu_1,\ldots is non-increasing over {0,1}\{0,1\}, so it crosses exactly once, and t⋆=min⁡{t≥1:νt=0}t^\star=\min\{t\ge1:\nu_t=0\} exists and is unique, with νt=1\nu_t=1 for all t<t⋆t<t^\star and νt=0\nu_t=0 for all t≥t⋆t\ge t^\star. For the final clause, νt⋆−1=1\nu_{t^\star-1}=1 supplies a within-budget success sequence from s(t⋆−1)s_{(t^\star-1)}. Its first action aa leaves the task solvable in the remaining budget, so a recoverability-preserving action existed at step t⋆t^\star, and the executed at⋆a_{t^\star} was not one, since it produced νt⋆=0\nu_{t^\star}=0.

Remarks. (i) The role of the budget. Recoverability is defined within the remaining budget, so even a diffuse failure with no single wrong click, an agent that dithers, loops, or re-reads pages, has a unique t⋆t^\star: the first step after which the shortest completion no longer fits in the budget. Without Assumption 4 the proposition is false, since an agent on an unbounded horizon can wander indefinitely without failure ever becoming irreversible. (ii) What t⋆t^\star is and is not. t⋆t^\star is an interventional quantity, the earliest step after which no policy could still succeed, which is what the localization instruction of Appendix B.1 asks for. By Assumption 5 it is a property of the executed actions and the environment alone: attainability depends only on the browser state and the remaining budget, so rationale tokens influence which action a policy will take but never whether success is still attainable. It need not coincide with the causal “root cause” a human would narrate (a misread page three steps earlier), which is why the localization study of §B.2 anchors annotators to the recoverability definition rather than to blame. (iii) Live sites. Assumption 5 holds exactly in a containerized benchmark and only approximately on the live web, where transitions are stochastic. There νt\nu_t generalizes to the optimal success probability from s(t)s_{(t)}, monotonicity can fail (a lucky refresh can restore a lost option), and t⋆t^\star must be defined relative to a threshold on νt\nu_t. Nothing in the paper relies on this extension. (iv) Infeasible tasks. If ν0=0\nu_0=0, the task is unsolvable from the start: Eq. 8 gives t⋆=1t^\star=1, but no recoverability-preserving action ever existed, and no correction can lead to success. Assumption 7 is thus a benchmark-design requirement, witnessed per task by any successful demonstration.

Proof of Proposition 2

Restrict Eq. 5 to a single supervised position ii and write pp for pi=πθ(yi∗∣⋅)p_i=\pi_\theta(y_i^\ast\mid\cdot), suppressing the index. Substituting eid=qi/pe^d_i=q_i/p into ki=eid−di−1k_i=e^d_i-d_i-1, position ii contributes

Li(p)=−ailog⁡p+bi(qip+log⁡pqi−1),(23)L_i(p)=-a_i\log p+b_i\left(\frac{q_i}{p}+\log\frac{p}{q_i}-1\right), \tag*{(23)}

with ai=wi/∑jwja_i=w_i/\sum_j w_j and bi=βγi/∑jγjb_i=\beta\gamma_i/\sum_j\gamma_j as in Appendix E. Differentiating,

dLidp=−aip+bi(−qip2+1p)=−ci(p)p,ci(p)=ai−bi(1−qip),(24)\frac{dL_i}{dp}=-\frac{a_i}{p}+b_i\left(-\frac{q_i}{p^2}+\frac{1}{p}\right)=-\frac{c_i(p)}{p},\qquad c_i(p)=a_i-b_i\left(1-\frac{q_i}{p}\right), \tag*{(24)}

recovering the throttle of Eq. 16. For bi>0b_i>0 the function ci(p)c_i(p) is strictly decreasing in pp, with lim⁡p→0+ci=+∞\lim_{p\to0+}c_i=+\infty and ci→ai−bic_i\to a_i-b_i as p→∞p\to\infty, and for bi=0b_i=0 it is the constant aia_i. If bi≤aib_i\le a_i, then ci(p)=(ai−bi)+biqi/p>0c_i(p)=(a_i-b_i)+b_iq_i/p>0 for every p∈(0,1]p\in(0,1] (here ai≥0a_i\ge0), so LiL_i is strictly decreasing on (0,1](0,1] and the minimum sits at the boundary p=1p=1 (approached as the target logit grows, since finite logits give p<1p<1). If bi>aib_i>a_i, solving ci(p)=0c_i(p)=0 gives the unique interior stationary point

pi⋆=qibibi−ai,(25)p_i^\star=\frac{q_i b_i}{b_i-a_i}, \tag*{(25)}

with ci>0c_i>0 below it and ci<0c_i<0 above it, so it is the minimum. Clipping at the boundary yields Eq. 17. The minimization can also be checked without calculus, which is how the Lean proof does it. With p^=qibi/(bi−ai)\hat p=q_i b_i/(b_i-a_i) and bi>aib_i>a_i, Li(p)−Li(p^)=qibip[p^/p−1−log⁡(p^/p)]≥0L_i(p)-L_i(\hat p)=\frac{q_i b_i}{p}[\hat p/p-1-\log(\hat p/p)]\ge0 for every p>0p>0, because log⁡x≤x−1\log x\le x-1. When bi≤aib_i\le a_i, or when p^>1\hat p>1, Li(p)−Li(1)=L_i(p)-L_i(1)= (bi−ai)log⁡p+biqi(1/p−1)≥0(b_i-a_i)\log p+b_iq_i(1/p-1)\ge0 on (0,1](0,1], by log⁡p≤0\log p\le0 in the first case and by log⁡p≥1−1/p\log p\ge1-1/p with bi−ai<qibib_i-a_i<q_ib_i in the second. For the full-softmax statement, note ∇z(−log⁡p)=p−ey\nabla_z(-\log p)=p-e_y and ∇zlog⁡p=ey−p\nabla_z\log p=e_y-p, while ∂ki/∂log⁡p=1−edi=1−qi/p\partial k_i/\partial\log p=1-e^{d_i}=1-q_i/p. Combining gives Eq. (16), which vanishes iff ci=0c_i=0 or p=eyp=e_y. Under gradient flow from the initialization p=qp=q (the reference’s full distribution, since θ0=θref\theta_0=\theta_{\mathrm{ref}}), every logit moves along the SFT direction scaled by cic_i. The target logit rises at rate ci(1−p)c_i(1-p) and each off-target logit zvz_v falls at rate cipvc_i p_v, in proportion to its current probability, so the gap between two off-target logits zu−zvz_u-z_v moves at rate ci(pv−pu)c_i(p_v-p_u) and the more probable alternatives lose ground faster. The off-target distribution therefore flattens rather than keeping the reference’s shape, while pp rises toward pi⋆p_i^\star, where cic_i vanishes when pi⋆p_i^\star is interior.

We note that the closed form exists because the anchor is pointwise in pp. A full-distribution KL to πref\pi_{\mathrm{ref}} would couple every vocabulary coordinate and add a second, non-collinear term to Eq. (16). The tabular idealization treats each position’s logits as free and ignores parameter sharing across positions. It characterizes the force each token contributes, not the coupled optimum of the network. The clamp of did_i to [−20,8][-20,8] (Appendix § 7.6) is also outside the analysis. It is inactive for qie−8≤pi≤qie20q_i e^{-8}\le p_i\le q_i e^{20}, so Proposition 2 is unchanged for every token with qi≥e−20q_i\ge e^{-20} (below qie−8q_i e^{-8} the clamp only removes the anchor’s force, and LiL_i stays decreasing there). For rarer tokens LiL_i is again decreasing above qie20q_i e^{20}, so its minimum over (0,1](0,1] can move to pi=1p_i=1 even when pi⋆<1p_i^\star<1.

A single-round imitation bound: proof of Theorem 1

P1 is behavior cloning on teacher rollouts, whose error can compound quadratically in the horizon ([26]). P2–P4 implement the oracle that DAgger uses to make it linear ([27]), expert-quality labels at states drawn from dπθBCd_{\pi_{\theta_{\mathrm{BC}}}}, but in a setting the classical theory does not cover: the expert is black-box, answers only in text, runs for a single round rather than DAgger’s iterated no-regret scheme, and its labels can fail in ways an action oracle’s cannot (a mislocalized failure, a fluent reference to state that was never observed). This subsection accounts for these differences. Throughout, Assumptions 4–7 hold, RR is treated as ground truth (the LLM judge that implements it adds measurement noise orthogonal to this analysis), and success rates ρ(⋅)\rho(\cdot) average over the training-task distribution and any policy stochasticity.

The relabeled process. The comparator is the process π~\tilde{\pi} that the corpus of P2–P4 supervises. On a task whose logged seed rollout succeeded, π~\tilde{\pi} replays that rollout and nothing is edited. On a task whose seed rollout failed with localization t′t', π~\tilde{\pi} replays the logged responses through step t′−1t'-1 and then hands control to the teacher-as-agent of Appendix B.1, style-conditioned exactly as in P4, which plays the episode out closed-loop from ht′h_{t'}. All quantities are conditional on the logged P2 rollouts, one per task, so the replay is exact and π~\tilde{\pi} is a policy of the task. Accordingly ρBC\rho_{\mathrm{BC}} is the fraction of tasks whose logged rollout succeeded, which estimates ρ(πθBC)\rho(\pi_{\theta_{\mathrm{BC}}}) because P2 rolls out at temperature 0.01 (Appendix C.3).

Error terms. All are population quantities, conditioned on failed seed rollouts where indicated:

εloc=Pr⁡[t′>t⋆∣seed rollout failed],\varepsilon_{\mathrm{loc}}=\Pr\left[t'>t^\star\mid\text{seed rollout failed}\right],

late localization (P3),

εcorr=Pr⁡[teacher-as-agent fails from ht′∣failed, t′≤t⋆],\varepsilon_{\mathrm{corr}}=\Pr\left[\text{teacher-as-agent fails from }h_{t'}\mid\text{failed},\ t'\le t^\star\right],

corrector capacity (P4),

δt=Eh∼dπ~t[TV⁡(πθWD(⋅∣h),π~(⋅∣h))],\delta_t=\mathbb{E}_{h\sim d_{\tilde{\pi}}^t}\left[\operatorname{TV}\left(\pi_{\theta_{\mathrm{WD}}}(\cdot\mid h),\tilde{\pi}(\cdot\mid h)\right)\right],

student disagreement,

where dπ~td_{\tilde{\pi}}^t is the step-tt history distribution of the relabeled process and the total variation is over the full structured response yy. Remark iii explains why the action alone does not suffice. We write εˉ=1T∑t=1Tδt\bar{\varepsilon}=\frac{1}{T}\sum_{t=1}^T\delta_t for the per-step disagreement of Theorem 1.

Lemma 3 (Imitation on a deterministic harness). *For any two policies π,π~\pi,\tilde{\pi} on the harness of § 3.1,

ρ(π~)−ρ(π)≤∑t=1TEh∼dπ~t[TV⁡(π(⋅∣h),π~(⋅∣h))].\rho(\tilde{\pi})-\rho(\pi)\le\sum_{t=1}^{T}\mathbb{E}_{h\sim d_{\tilde{\pi}}^t}\left[\operatorname{TV}\left(\pi(\cdot\mid h),\tilde{\pi}(\cdot\mid h)\right)\right].

Proof. By Assumption 5 a history is determined by the task and the responses emitted so far. Write hyh_y for the history after response yy at hh, and Vπ(h)V_\pi(h) for the probability that π\pi succeeds from hh within the remaining budget, so that Vπ(h)=∑yπ(y∣h)Vπ(hy)V_\pi(h)=\sum_y\pi(y\mid h)V_\pi(h_y), with Vπ=RV_\pi=R once the budget is spent. At every history,

Vπ~(h)−Vπ(h)=∑yπ~(y∣h)(Vπ~(hy)−Vπ(hy))+∑y(π~(y∣h)−π(y∣h))Vπ(hy).V_{\tilde{\pi}}(h)-V_{\pi}(h)=\sum_y\tilde{\pi}(y\mid h)\left(V_{\tilde{\pi}}(hy)-V_{\pi}(hy)\right)+\sum_y\left(\tilde{\pi}(y\mid h)-\pi(y\mid h)\right)V_{\pi}(hy).

Both rows sum to one and 0≤Vπ≤10\leq V_{\pi}\leq1, so the second sum equals ∑y(π~(y∣h)−π(y∣h))(Vπ(hy)−12)≤12∑y∣π~(y∣h)−π(y∣h)∣=TV⁡(π(⋅∣h),π~(⋅∣h))\sum_y(\tilde{\pi}(y\mid h)-\pi(y\mid h))(V_{\pi}(hy)-\frac{1}{2})\leq\frac{1}{2}\sum_y|\tilde{\pi}(y\mid h)-\pi(y\mid h)|=\operatorname{TV}(\pi(\cdot\mid h),\tilde{\pi}(\cdot\mid h)). The first sum is the same gap one step later, averaged under π~\tilde{\pi}. Unrolling it from the initial history over the TT steps and averaging over tasks gives the claim. This is the coupling argument in recursive form: the second sum bounds the probability that a maximal coupling of π(⋅∣h)\pi(\cdot\mid h) and π~(⋅∣h)\tilde{\pi}(\cdot\mid h) separates the two responses at hh, and the first follows the coupled process along π~\tilde{\pi} while they agree.

Theorem 3 (Single-round relabeling bound, formal). Under Assumptions 4–7,

1−ρ(πθWD)≤(1−ρBC)(εloc+εcorr)+∑t=1Tδt.(26)1-\rho(\pi_{\theta_{\mathrm{WD}}})\leq(1-\rho_{\mathrm{BC}})(\varepsilon_{\mathrm{loc}}+\varepsilon_{\mathrm{corr}})+\sum_{t=1}^{T}\delta_t. \tag*{(26)}

Proof. First bound the relabeled process. On tasks whose logged seed rollout succeeds, probability ρBC\rho_{\mathrm{BC}}, π~\tilde{\pi} replays that rollout and succeeds, by Assumption 5. On a failed rollout, distinguish the localization outcomes. If t′>t⋆t'>t^\star, then t′−1≥t⋆t'-1\geq t^\star, so νt′−1=0\nu_{t'-1}=0 by Proposition 1 and no continuation from ht′h_{t'} within the remaining budget can succeed: the episode is lost regardless of the teacher. If t′≤t⋆t'\leq t^\star, then νt′−1=1\nu_{t'-1}=1, the state is recoverable, and the teacher-as-agent fails with probability εcorr\varepsilon_{\mathrm{corr}} by definition. Hence

1−ρ(π~)≤(1−ρBC)(εloc+(1−εloc)εcorr)≤(1−ρBC)(εloc+εcorr).1-\rho(\tilde{\pi})\leq(1-\rho_{\mathrm{BC}})(\varepsilon_{\mathrm{loc}}+(1-\varepsilon_{\mathrm{loc}})\varepsilon_{\mathrm{corr}})\leq(1-\rho_{\mathrm{BC}})(\varepsilon_{\mathrm{loc}}+\varepsilon_{\mathrm{corr}}).

The first inequality does not use the lateness of the localization: a late episode is counted as a failure, which bounds its failure probability whatever the teacher does there, so it holds for any localization. Proposition 1 makes the count exact, since a late episode is then lost with probability one, and Remark (i) uses this. Apply Lemma 3 with π=πθWD\pi=\pi_{\theta_{\mathrm{WD}}} and combine.

Corollary 3 (Regime decomposition). Partition the states of dtπ~d_t^{\tilde{\pi}} into three cells. The first holds states of solved seed episodes, where π~\tilde{\pi} replays the logged rollout and no record supervises. The second holds states of failed episodes up to and including t′t', where the corpus supervises exactly the histories π~\tilde{\pi} visits (replay records before t′t', the edited record at t′t'). The third holds post-correction states t>t′t>t' of failed episodes, which no record covers. Writing εret,εfit,εrec\varepsilon_{\mathrm{ret}},\varepsilon_{\mathrm{fit}},\varepsilon_{\mathrm{rec}} for the per-step average of TV⁡(πθWD,π~)\operatorname{TV}(\pi_{\theta_{\mathrm{WD}}},\tilde{\pi}) on each cell respectively,

∑t=1Tδt≤T(ρBCεret+(1−ρBC)(εfit+εrec)),(27)\sum_{t=1}^{T}\delta_t\leq T\left(\rho_{\mathrm{BC}}\varepsilon_{\mathrm{ret}}+(1-\rho_{\mathrm{BC}})(\varepsilon_{\mathrm{fit}}+\varepsilon_{\mathrm{rec}})\right), \tag*{(27)}

since each episode contributes at most TT steps to its cells. With εˉ=1T∑tδt\bar{\varepsilon}=\frac{1}{T}\sum_t\delta_t this is the second inequality of (18). The bound adds the two failed-episode cells; weighting each instead by its share of those episodes’ steps makes it an equality.

Remarks. (i) The DAgger correspondence. εfit\varepsilon_{\mathrm{fit}} plays the role of DAgger’s training loss on the aggregated on-policy dataset, and TεˉT\bar{\varepsilon} its linear-in-horizon error term [27]. The teacher term can be measured directly. A takeover run, in which the teacher plays the episode out from ht′h_{t'}, reports the bracket εloc+(1−εloc)εcorr\varepsilon_{\mathrm{loc}}+(1-\varepsilon_{\mathrm{loc}})\varepsilon_{\mathrm{corr}} of the proof directly, since a late localization fails with probability one, so (1−ρBC)(1-\rho_{\mathrm{BC}}) times the measured takeover failure rate is a tighter teacher term than the εloc+εcorr\varepsilon_{\mathrm{loc}}+\varepsilon_{\mathrm{corr}} that (26) prints and needs no separate estimate of εloc\varepsilon_{\mathrm{loc}}. (ii) Teacher capacity sets the bound’s floor, and the degradation is graceful. A weaker teacher enters the bound three times, through ρBC\rho_{\mathrm{BC}} (worse P1 demonstrations, themselves subject to the off-policy O(T2ε)O(T^2\varepsilon) regime above), through εloc\varepsilon_{\mathrm{loc}}, and through εcorr\varepsilon_{\mathrm{corr}}, each linearly. The bound is one-directional: it caps failure and does not preclude the student empirically exceeding the teacher-in-harness, but any such gain is outside the guarantee. (iii) Why the disagreement is over the full response. ht+1h_{t+1} contains yty_t, so two policies that always agree on the executed action but phrase their rationale differently still diverge in history, and the coupling of Lemma 3 breaks. This is the truncated-history argument of Appendix A.4 as it appears in the bound. Rationale tokens are part of the harness state, which is why the method supervises and anchors them. Action-level agreement suffices exactly when rationale differences never change a later decision, a policy-dependent property the anchor pushes toward but does not certify. (iv) The single-round residual. εrec\varepsilon_{\mathrm{rec}} lives on the states the teacher’s correction steers into, which no record covers by design, since edits never execute (P4ii). Two mechanisms keep it small: recovered states resemble the teacher-demonstration states P1 already cloned, and the anchor limits how far πθWD\pi_{\theta_{\mathrm{WD}}} moves from πθBC\pi_{\theta_{\mathrm{BC}}} on corpus tokens, which limits drift where the corpus is silent only indirectly, through shared parameters. Iterating P2–P4 from πθWD\pi_{\theta_{\mathrm{WD}}} would convert εrec\varepsilon_{\mathrm{rec}} into supervised coverage, which is DAgger’s aggregation. Likewise εret\varepsilon_{\mathrm{ret}} is the retention term the anchor of §3.3.2 targets: on solved episodes the reference behavior is the seed’s own, so any drift there is pure loss. Because the anchor is a pointwise, role-masked penalty on corpus tokens (§3.3.2), it lowers εret\varepsilon_{\mathrm{ret}} and εrec\varepsilon_{\mathrm{rec}} by limiting drift, but it does not bound either through a distributional inequality.

(v) What the deep-suffix records do. Edited records at k>t′k > t' sit at seed-visited states that are unrecoverable whenever t′=t⋆t' = t^\star (Proposition 1), so they cannot rescue those episodes and do not appear in Eq. (26). They teach the policy how to behave at bad states and influence the bound only through generalization, that is, through lowering εfit\varepsilon_{\mathrm{fit}} and εrec\varepsilon_{\mathrm{rec}} at nearby states. The grounding filter of Algorithm 1 removes a kind of label error that an action oracle cannot make, fluent references to state that was never observed, which would otherwise corrupt these records.

Proofs for §E.3

Proof of Lemma 1. Write p=p(i)\mathbf{p} = \mathbf{p}^{(i)} for the student’s next-token distribution at position ii, y=y∗\mathbf{y} = \mathbf{y}^* for the target, and py=e−CEip_y = e^{-\mathrm{CE}_i} for its probability. Since CEi=−log⁡softmax⁡(z(i))y\mathrm{CE}_i = -\log\operatorname{softmax}(\mathbf{z}^{(i)})_y, the gradient is ∇z(i)CEi=p−ey\nabla_{\mathbf{z}^{(i)}}\mathrm{CE}_i = \mathbf{p} - \mathbf{e}_y, so ∥∇z(i)CEi∥22=(1−py)2+∑v≠ypv2\lVert\nabla_{\mathbf{z}^{(i)}}\mathrm{CE}_i\rVert_2^2 = (1-p_y)^2 + \sum_{v\ne y}p_v^2. The sum is non-negative, which gives the lower bound, and ∑v≠ypv2≤(∑v≠ypv)2=(1−py)2\sum_{v\ne y}p_v^2 \le\left(\sum_{v\ne y}p_v\right)^2 = (1-p_y)^2 because every pv≥0p_v \ge0, which gives the upper bound.

Proof of Proposition 3. (i) By Eq. (1) pooled over a set CC, log⁡PPLC=1nC∑i∈ICCEi\log\mathrm{PPL}_C = \frac{1}{n_C}\sum_{i\in I_C}\mathrm{CE}_i, so ∑i∈ICCEi=nClog⁡PPLC\sum_{i\in I_C}\mathrm{CE}_i = n_C\log\mathrm{PPL}_C. The uniform loss restricted to Irat∪IactI_{\mathrm{rat}}\cup I_{\mathrm{act}} is 1nrat+nact\frac{1}{n_{\mathrm{rat}}+n_{\mathrm{act}}} times the sum of the two, and the action’s share is the ratio in Eq. (19). (ii) By Lemma 1 and 1−e−x≤x1-e^{-x}\le x for x≥0x\ge0, Gact≤2∑i∈Iact(1−e−CEi)≤2∑i∈IactCEi=XG_{\mathrm{act}}\le\sqrt{2}\sum_{i\in I_{\mathrm{act}}}(1-e^{-\mathrm{CE}_i})\le\sqrt{2}\sum_{i\in I_{\mathrm{act}}}\mathrm{CE}_i=X. The function x↦1−e−xx\mapsto1-e^{-x} is concave, so on [0,Λ][0,\Lambda] it lies above its chord, 1−e−x≥(1−e−Λ)x/Λ1-e^{-x}\ge(1-e^{-\Lambda})x/\Lambda. With Assumption 1 and Lemma 1, Grat≥1−e−ΛΛ∑i∈IratCEi=YG_{\mathrm{rat}}\ge\frac{1-e^{-\Lambda}}{\Lambda}\sum_{i\in I_{\mathrm{rat}}}\mathrm{CE}_i=Y. Finally t↦t/(t+s)t\mapsto t/(t+s) is increasing in tt and decreasing in ss, so Gact/(Gact+Grat)≤Gact/(Gact+Y)≤X/(X+Y)G_{\mathrm{act}}/(G_{\mathrm{act}}+G_{\mathrm{rat}})\le G_{\mathrm{act}}/(G_{\mathrm{act}}+Y)\le X/(X+Y).

Scope. The proposition is about gradients with respect to the logits, similar to Proposition 2.

Proof of Theorem 2. Under Assumption 3 the set U\mathcal{U} of segments the student writes has Pr⁡[U]=∏j∈Uκj∏j∉U(1−κj)\Pr[\mathcal{U}] = \prod_{j\in\mathcal{U}}\kappa_j\prod_{j\notin\mathcal{U}}(1-\kappa_j), and under Assumption 2

Pπ(⟨A∗⟩∣h)=∑UPr⁡[U]eα0∏j∈UeΔj=eα0∏j=1n(1−κj+κjeΔj).P_{\pi}(\langle A^*\rangle\mid h)=\sum_{\mathcal{U}}\Pr[\mathcal{U}]e^{\alpha_0}\prod_{j\in\mathcal{U}}e^{\Delta_j}=e^{\alpha_0}\prod_{j=1}^{n}(1-\kappa_j+\kappa_je^{\Delta_j}).

since the sum over subsets factorizes coordinate by coordinate. Taking logarithms and differentiating the jj-th factor with respect to log⁡κj\log\kappa_j gives Eq. (21). Writing a=eΔja=e^{\Delta_j}, μj=κj(a−1)/(1−κj+κja)\mu_j=\kappa_j(a-1)/(1-\kappa_j+\kappa_ja) has derivative in aa equal to [κj(1−κj+κja)−κj2(a−1)]/(1−κj+κja)2[\kappa_j(1-\kappa_j+\kappa_ja)-\kappa_j^2(a-1)]/(1-\kappa_j+\kappa_ja)^2, which simplifies to κj(1−κj)/(1−κj+κja)2>0\kappa_j(1-\kappa_j)/(1-\kappa_j+\kappa_ja)^2>0, so μj\mu_j is strictly increasing in Δj\Delta_j. It vanishes at a=1a=1 and is negative for a<1a<1.

For the ordering claim, the rate hypothesis says a step on LSWL_{\mathrm{SW}} raises log⁡κj\log\kappa_j by ηvj\eta v_j for a common η>0\eta>0. To first order the change in log⁡Pπ(⟨A∗⟩∣h)\log P_\pi(\langle A^*\rangle\mid h) is then η∑jμjvj\eta\sum_j\mu_jv_j by Eq. (21). With κj=κ\kappa_j=\kappa for all jj, μj\mu_j is an increasing function of Δj\Delta_j alone, so the μj\mu_j and the Δj\Delta_j have the same order. The rearrangement inequality states that for two finite real sequences the sum of products is maximized when both are sorted the same way, so among all assignments of a fixed multiset {vj}\{v_j\} to the segments, ∑jμjvj\sum_j\mu_jv_j is maximized by assigning the weights in the order of Δj\Delta_j. The maximizing assignment is a function of the order of the Δj\Delta_j alone, which is what Eq. 10 computes, up to ties, which the average rank resolves without changing the maximum.

Scope. Assumption 2 makes the leave-one-out score exact and removes interactions among segments, so a segment that matters only jointly with another is scored as inert. Assumption 3 treats the segments as independently emitted and prices a nat of log-probability on a segment as a nat of premium, which is Definition 1 applied to that segment. The rate hypothesis holds in logit space when the rationale tokens of a step have equal gradient norm at initialization and its segments have equal token length. A logit-space step of size η\eta on LSW\mathcal{L}_{\mathrm{SW}} at a token ii with weight wiw_i moves the logits by −ηwi(p−ey)-\eta w_i(\mathbf{p}-\mathbf{e}_y) up to the common normalizer ∑kwk\sum_k w_k, and since ∇z(i)log⁡pi=ey−p\nabla_{\mathbf{z}^{(i)}}\log p_i=\mathbf{e}_y-\mathbf{p}, it raises log⁡pi\log p_i by ηwi∥p−ey∥2\eta w_i\lVert\mathbf{p}-\mathbf{e}_y\rVert^2 to first order. Summed over the tokens of sjs_j, it raises log⁡κj\log\kappa_j by ηvjgj\eta v_j g_j up to the normalizer, where gj=∑i∈sj∥p(i)−eyi∥2g_j=\sum_{i\in s_j}\lVert\mathbf{p}^{(i)}-\mathbf{e}_{y_i}\rVert^2, so the rate is proportional to vjv_j only when the gjg_j agree. Equal surprisal across the step’s rationale tokens makes these squared norms equal within a factor of two by Lemma 1, and equal when the off-target mass is spread alike. In general the first-order gain is η∑jμjgjvj\eta\sum_j\mu_j g_jv_j and the optimal order is by μjgj\mu_jg_j. Here μj\mu_j also depends on κj\kappa_j: by Eq. (21) its magnitude grows with κj\kappa_j, so it increases with κj\kappa_j when Δj>0\Delta_j>0 and decreases when Δj<0\Delta_j<0.

Proof of Corollary 2. By Proposition 2, if bi>aib_i>a_i the per-token optimum is pi∗=min⁡{1,qibi/(bi−ai)}p_i^*=\min\{1,q_i b_i/(b_i-a_i)\}, so log⁡(pi∗/qi)≤log⁡(bi/(bi−ai))=−log⁡(1−ai/bi)\log(p_i^*/q_i)\le\log(b_i/(b_i-a_i))=-\log(1-a_i/b_i). With ai=wi/∑jwja_i=w_i/\sum_jw_j and bi=βγi/∑jγjb_i=\beta\gamma_i/\sum_j\gamma_j, ai/bi=wiγi⋅∑jγj∑jwj⋅1β=βˉi/βa_i/b_i=\frac{w_i}{\gamma_i}\cdot\frac{\sum_j\gamma_j}{\sum_jw_j}\cdot\frac{1}{\beta}=\bar{\beta}_i/\beta, which is Eq. (22), and bi>aib_i>a_i is β>βˉi\beta>\bar{\beta}_i (Corollary 1). Training starts at pi=qip_i=q_i (§3.3.2), so the surprisal shed on token ii between initialization and the per-token optimum is log⁡pi∗−log⁡qi\log p_i^*-\log q_i. If bi≤aib_i\le a_i the optimum is pi∗=1p_i^*=1 and the shed surprisal is the full CEi\mathrm{CE}_i at initialization. The budget −log⁡(1−βˉi/β)-\log(1-\bar{\beta}_i/\beta) is decreasing in β\beta and increasing in βˉi∝wi\bar{\beta}_i\propto w_i. On tokens with γi≈0\gamma_i\approx0, bi≈0<aib_i\approx0<a_i and there is no cap. □

Declaration of LLM Usage

The authors acknowledge the use of LLMs to polish the draft, to brainstorm ideas and research directions, to orchestrate experiments, to formalize and check the proofs in Lean, and to review code. We take full responsibility for the paper’s content and correctness.

Reproducibility Statement

We have taken several steps to ensure our results are reproducible. The complete source code is included in the supplementary material and will be released publicly upon acceptance. It comes with a README describing environment setup, dependencies, and each component. Every proposition, lemma, corollary, and theorem of the theory appendix is formalized in Lean 4 on finite models of the setting, and the formalization is included in the supplementary material. Its README maps each result to its Lean declaration and states the modeling choices and what is trusted. All datasets are publicly available and have been cited.

References

  1. [1]Rishabh Agarwal, Nino Vieillard, Yongchao Zhou, Piotr Stanczyk, Sabela Ramos Garea, Matthieu Geist, and Olivier Bachem. On-policy distillation of language models: Learning from self-generated mistakes. In The Twelfth International Conference on Learning Representations, 2024.arxiv.org/abs/2306.13649
  2. [2]Hao Bai, Yifei Zhou, Mert Cemri, Jiayi Pan, Alane Suhr, Sergey Levine, and Aviral Kumar. DigiRL: Training in-the-wild device-control agents with autonomous reinforcement learning. In Advances in Neural Information Processing Systems, volume 37, 2024.
  3. [3]Sanjiban Choudhury and Paloma Sodhi. Better than your teacher: LLM agents that learn from privileged AI feedback. In The Thirteenth International Conference on Learning Representations, 2025. URL https://openreview.net/forum?id=st7XqFgBAH.
  4. [5]Xiang Deng, Yu Gu, Boyuan Zheng, Shijie Chen, Samuel Stevens, Boshi Wang, Huan Sun, and Yu Su. Mind2Web: Towards a generalist agent for the web. In Thirty-seventh Conference on Neural Information Processing Systems Datasets and Benchmarks Track, 2023. URL https://openreview.net/forum?id=kiYqbO3wqw.arxiv.org/abs/2306.06070
  5. [7]Yuxian Gu, Li Dong, Furu Wei, and Minlie Huang. MiniLLM: Knowledge distillation of large language models. In The Twelfth International Conference on Learning Representations, 2024. URL https://openreview.net/forum?id=5h0qf7IBZZ.DOI
  6. [8]Hongliang He, Wenlin Yao, Kaixin Ma, Wenhao Yu, Yong Dai, Hongming Zhang, Zhenzhong Lan, and Dong Yu. WebVoyager: Building an end-to-end web agent with large multimodal models. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics, 2024.
  7. [9]Hongliang He, Wenlin Yao, Kaixin Ma, Wenhao Yu, Hongming Zhang, Tianqing Fang, Zhenzhong Lan, and Dong Yu. OpenWebVoyager: Building multimodal web agents via iterative real-world exploration, feedback and optimization. In Wanxiang Che, Joyce Nabende, Ekaterina Shutova, and Mohammad Taher Pilehvar (eds.), Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 27545–27564, Vienna, Austria, July 2025. Association for Computational Linguistics. ISBN 979-8-89176-251-0. doi: 10.18653/v1/2025.acl-long.1336. URL https://aclanthology.org/2025.acl-long.1336/.
  8. [10]Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2015.arxiv.org/abs/1503.02531
  9. [11]Minda Hu, Tianqing Fang, Jianshu Zhang, Jun-Yu Ma, Zhishong Zhang, Jingyan Zhou, Hongming Zhang, Haitao Mi, Dong Yu, and Irwin King. WebCoT: Enhancing web agent reasoning by reconstructing chain-of-thought in reflection, branching, and rollback. In Findings of the Association for Computational Linguistics: EMNLP 2025, 2025.
  10. [12]Jonas Hübotter, Frederike Lübeck, Lejs Deen Behric, Anton Baumann, Marco Bagatella, Daniel Marta, Ido Hakimi, Idan Shenfeld, Thomas Kleine Buenning, Carlos Guestrin, and Andreas Krause. Reinforcement learning via self-distillation. In Forty-third International Conference on Machine Learning, 2026. URL https://openreview.net/forum?id=QfkxyRiZz.
  11. [13]Md Farhan Ishmam and Kenneth Marino. TimeWarp: Evaluating web agents by revisiting the past. In Fortieth Conference on Neural Information Processing Systems Evaluations and Datasets Track, 2026. URL https://arxiv.org/abs/2603.04949. To appear.
  12. [14]Leslie Pack Kaelbling, Michael L Littman, and Anthony R Cassandra. Planning and acting in partially observable stochastic domains. Artificial Intelligence, 101(1-2):99–134, 1998.
  13. [15]Moo Jin Kim, Karl Pertsch, Siddharth Karamcheti, Ted Xiao, Ashwin Balakrishna, Suraj Nair, Rafael Rafailov, Ethan P Foster, Pannag R Sanketi, Quan Vuong, Thomas Kollar, Benjamin Burchfiel, Russ Tedrake, Dorsa Sadigh, Sergey Levine, Percy Liang, and Chelsea Finn. Open-vla: An open-source vision-language-action model. In Pulkit Agrawal, Oliver Kroemer, and Wolfram Burgard (eds.), Proceedings of The 8th Conference on Robot Learning, volume 270 of Proceedings of Machine Learning Research, pp. 2679–2713. PMLR, 06–09 Nov 2025. URL https://proceedings.mlr.press/v270/kim25c.html.DOI
  14. [16]Yoon Kim and Alexander M Rush. Sequence-level knowledge distillation. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pp. 1317–1327, 2016.arxiv.org/abs/1606.07947
  15. [17]Jongwoo Ko, Sungnyun Kim, Tianyi Chen, and Se-Young Yun. DistiLLM: Towards streamlined distillation for large language models. In Proceedings of the 41st International Conference on Machine Learning, 2024.arxiv.org/abs/2402.03898
  16. [18]Niklas Lauffer, Xiang Deng, Srivatsa R Kundurthy, Brad Kenstler, and Jeff Da. Imitation learning for multi-turn LM agents via on-policy expert corrections. In Forty-third International Conference on Machine Learning, 2026. URL https://openreview.net/forum?id=1OLA4SUA50.arxiv.org/abs/2512.14895
  17. [19]Changhao Li, Rushi Qiang, Jiawei Huang, Chenxiao Gao, Chao Zhang, Niao He, and Bo Dai. Revisiting DAgger in the era of LLM-agents. arXiv preprint arXiv:2605.12913, 2026a.arxiv.org/abs/2605.12913
  18. [20]Xiaozhe Li, Tianyi Lyu, Yang Li, Yichuan Ma, Peiji Li, Linyang Li, Qipeng Guo, Dahua Lin, and Kai Chen. What and when to distill: Selective hindsight distillation for multi-turn agents. arXiv preprint arXiv:2605.19447, 2026b.
  19. [21]Yijiang Li, Bingyang Wang, Yijun Liang, Yunjie Tian, Di Fu, and Nuno Vasconcelos. On-policy self-distillation without any supervision. arXiv preprint arXiv:2608.06296, 2026c.arxiv.org/abs/2608.06296
  20. [22]Kevin Lu and Thinking Machines Lab. On-policy distillation. Thinking Machines Lab: Connection-ism, 2025. https://thinkingmachines.ai/blog/on-policy-distillation.
  21. [23]Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. Training language models to follow instructions with human feedback. In Advances in Neural Information Processing Systems, volume 35, pp. 27730–27744, 2022.arxiv.org/abs/2203.02155
  22. [24]Zehan Qi, Xiao Liu, Iat Long Long, Hanyu Lai, Xueqiao Sun, et al. WebRL: Training LLM web agents via self-evolving online curriculum reinforcement learning. In The Thirteenth International Conference on Learning Representations, 2025.arxiv.org/abs/2411.02337
  23. [25]Xuan Ren, Biao Wu, and Lingqiao Liu. I learn better if you speak my language: Understanding the superior performance of fine-tuning large language models with LLM-generated responses. In Yaser Al-Onaizan, Mohit Bansal, and Yun-Nung Chen (eds.), Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, pp. 10225–10245, Miami, Florida, USA, November 2024. Association for Computational Linguistics. doi: 10.18653/v1/2024.emnlp-main.571. URL https://aclanthology.org/2024.emnlp-main.571/.DOI
  24. [26]Stéphane Ross and Drew Bagnell. Efficient reductions for imitation learning. In Proceedings of the Thirteenth International Conference on Artificial Intelligence and Statistics (AISTATS), pp. 661–668, 2010.
  25. [27]Stéphane Ross, Geoffrey J Gordon, and J Andrew Bagnell. A reduction of imitation learning and structured prediction to no-regret online learning. In Proceedings of the Fourteenth International Conference on Artificial Intelligence and Statistics (AISTATS), pp. 627–635, 2011.arxiv.org/abs/1011.0686
  26. [28]John Schulman. Approximating KL divergence, 2020. http://joschu.net/blog/kl-approx.html.
  27. [29]Zhihong Shao, Peiyi Wang, Qihao Zhu, Runxin Xu, Junxiao Song, Xiao Bi, Haowei Zhang, Mingchuan Zhang, YK Li, Y Wu, et al. DeepseekMath: Pushing the limits of mathematical reasoning in open language models. arXiv preprint arXiv:2402.03300, 2024.arxiv.org/abs/2402.03300
  28. [30]Yixiao Song, Katherine Thai, Chau Minh Pham, Yapei Chang, Mazin Nadaf, and Mohit Iyyer. BEARCUBS: A benchmark for computer-using web agents. In Second Conference on Language Modeling, 2025. URL https://openreview.net/forum?id=0JzWiigkUy.arxiv.org/abs/2503.07919
  29. [31]Gemma Team, Sherif El Abd, Vaibhav Aggarwal, Robin Algayres, Alek Andreev, Olivier Bachem, Ian Ballantyne, Cormac Brick, Victor Cärbune, Michelle Casbon, et al. Gemma 4 technical report. arXiv preprint arXiv:2607.02770, 2026.arxiv.org/abs/2607.02770
  30. [33]Zhepei Wei, Wenlin Yao, Yao Liu, Weizhi Zhang, Qin Lu, Liang Qiu, Changlong Yu, Puyang Xu, Chao Zhang, Bing Yin, Hyokun Yun, and Lihong Li. WebAgent-r1: Training web agents via end-to-end multi-turn reinforcement learning. In Christophorus Christodoulopoulos, Tannoy Chakraborty, Carolyn Rose, and Violet Peng (eds.), Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing, pp. 7909–7928, Suzhou, China, November 2025. Association for Computational Linguistics. ISBN 979-8-89176-332-6. doi: 10.18653/v1/2025.emnlp-main.401. URL https://aclanthology.org/2025.emnlp-main.401/.DOI
  31. [34]Tianbao Xie, Danyang Zhang, Jixuan Chen, Xiaochuan Li, Siheng Zhao, Ruisheng Cao, Toh Jing Hua, Zhoujun Cheng, Dongchan Shin, Fangyu Lei, Yitao Liu, Yiheng Xu, Shuyan Zhou, Silvio Savarese, Caiming Xiong, Victor Zhong, and Tao Yu. OSWorld: Benchmarking multimodal agents for open-ended tasks in real computer environments. In The Thirty-eighth Conference on Neural Information Processing Systems Datasets and Benchmarks Track, 2024. URL https://openreview.net/forum?id=tN61DTr4Ed.arxiv.org/abs/2404.07972
  32. [35]Tianci Xue, Weijian Qi, Tianneng Shi, Chan Hee Song, Boyu Gou, Dawn Song, Huan Sun, and Yu Su. An illusion of progress? Assessing the current state of web agents. In Conference on Language Modeling (COLM), 2025.arxiv.org/abs/2504.01382
  33. [36]Jianwei Yang, Hao Zhang, Feng Li, Xueyan Zou, Chunyuан Li, and Jianfeng Gao. Set-of-mark prompting unleashes extraordinary visual grounding in GPT-4V. arXiv preprint arXiv:2310.11441, 2023.arxiv.org/abs/2310.11441
  34. [37]Woongyeng Yeo, Yumin Choi, Taekyung Ki, and Sung Ju Hwang. HinT-SD: Targeted hindsight self-distillation for long-horizon agents. arXiv preprint arXiv:2605.17873, 2026.DOI
  35. [38]Zheng Yuan, Hongyi Yuan, Chengpeng Li, Guanting Dong, Keming Lu, Chuanqi Tan, Chang Zhou, and Jingren Zhou. Scaling relationship on learning mathematical reasoning with large language models. arXiv preprint arXiv:2308.01825, 2023.arxiv.org/abs/2308.01825
  36. [39]Eric Zelikman, Yuhuai Wu, Jesse Mu, and Noah D. Goodman. STaR: Bootstrapping reasoning with reasoning. In Advances in Neural Information Processing Systems, volume 35, 2022.arxiv.org/abs/2203.14465
  37. [40]Siyan Zhao, Zhihui Xie, Mengchen Liu, Jing Huang, Guan Pang, Feiyu Chen, and Aditya Grover. Self-distilled reasoner: On-policy self-distillation for large language models. In ICLR 2026 Workshop on Lifelong Agents: Learning, Aligning, Evolving, 2026. URL https://openreview.net/forum?id=31wkVZXEaJ.arxiv.org/abs/2601.18734
  38. [41]Lianmin Zheng, Wei-Lin Chiang, Ying Sheng, Siyuan Zhuang, Zhanghao Wu, Yonghao Zhuang, Zi Lin, Zhuohan Li, Dacheng Li, Eric Xing, et al. Judging LLM-as-a-judge with MT-Bench and chatbot arena. In Advances in Neural Information Processing Systems, volume 36, 2023.arxiv.org/abs/2306.05685
  39. [42]Shuyan Zhou, Frank F Xu, Hao Zhu, Xuhui Zhou, Robert Lo, Abishek Sridhar, Xianyi Cheng, Tianyue Ou, Fontan Fisk, Daniel Fried, Uri Alon, and Graham Neubig. WebArena: A realistic web environment for building autonomous agents. In The Twelfth International Conference on Learning Representations, 2024.arxiv.org/abs/2307.13854
  40. [43]Brianna Zitkovich, Tianhe Yu, Sichun Xu, Peng Xu, Ted Xiao, Fei Xia, Jialin Wu, Paul Wohlhart, Stefan Welker, Ayzaan Wahid, Quan Vuong, Vincent Vanhoucke, Huong Tran, Radu Soricut, Anikait Singh, Jaspiar Singh, Pierre Sermanet, Pannag R. Sanketi, Grecia Salazar, Michael S. Ryoo, Krista Reymann, Kanishka Rao, Karl Pertsch, Igor Mordatch, Henryk Michalewski, Yao Lu, Sergey Levine, Lisa Lee, Tsang-Wei Edward Lee, Isabel Leal, Yuheng Kuang, Dmitry Kalashnikov, Ryan Julian, Nikhil J. Joshi, Alex Irpan, Brian Ichter, Jasmine Hsu, Alexander Herzog, Karol Hausman, Keerthana Gopalakrishnan, Chuyuan Fu, Pete Florence, Chelsea Finn, Kumar Avinava Dubey, Danny Driess, Tianli Ding, Krzysztof Marcin Choromanski, Xi Chen, Yevgen Chebotar, Justice Carbajal, Noah Brown, Anthony Brohan, Montserrat Gonzalez Arenas, and Kehang Han. Rt-2: Vision-language-action models transfer web knowledge to robotic control. In Jie Tan, Marc Toussaint, and Kourosh Darvish (eds.), Proceedings of The 7th Conference on Robot Learning, volume 229 of Proceedings of Machine Learning Research, pp. 2165–2183. PMLR, 06–09 Nov 2023. URL https://proceedings.mlr.press/v229/zikovich23a.html.arxiv.org/abs/2307.15818

Paper details

vlnc:W_vjfz56xu
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

LLMs

View statement
Looking for related papers…
Contents