July 03, 2026
Small language models are attractive backbones for interactive agents, but direct distillation from strong teacher trajectories often turns rich multi-turn behavior into one-shot imitation targets. This is inefficient in long-horizon environments, where early decisions shape later states and rewards. We propose Prefix-GRPO, a reinforcement learning framework that decomposes teacher trajectories into replay-aligned prefix queries and online continuations. Each prefix is replayed in the environment to recover a valid intermediate state, after which the student continues online interaction and receives task reward. Unlike response-only GRPO, Prefix-GRPO also applies clipped policy updates to historical assistant tokens inside the replayed prefix, using a policy-distilled SFT checkpoint to estimate their old log-probabilities. This unifies prefix learning and continuation learning within the same policy-optimization form. Experiments on TextCraft, BabyAI, and ALFWorld show that Prefix-GRPO improves small-model agents over distillation and standard RL baselines, while ablations show that replay alone is insufficient without explicit prefix-token optimization. The implementation and reproduction scripts are available at https://github.com/HappynessI/Prefix_GRPO.
Endowing small language models with robust agentic capabilities has emerged as a central challenge, as these models transition from static question answering to interactive decision-making in real-world environments. Compared with frontier-scale models, small models offer compelling advantages for high-frequency deployment, low-latency interaction, and private or on-device inference, making them promising backbones for specialized agents [1]. However, multi-turn agent tasks are substantially harder than static generation: each action changes the future observation distribution, so the model must maintain coherent state tracking, planning, action execution, and stopping behavior throughout a closed observation-action-feedback loop [2], [3].
Using strong teacher agents to generate high-quality interaction trajectories and then transfer them to small models is a natural approach [4]–[6]. Yet direct supervised distillation over full trajectories often teaches the surface form of teacher behavior rather than the underlying decision dynamics needed for long-horizon interaction. As a result, distilled small models may exhibit verbose reasoning, excessive tool use, unstable stopping, or other forms of inefficient behavior without learning which historical decisions are actually responsible for downstream success [7]–[9]. This creates a basic mismatch: teacher trajectories contain rich sequential decision structure, but standard distillation typically consumes them as one-shot imitation targets.
Recent work has begun to explore how demonstrations, historical prefixes, and off-policy trajectories can improve the data efficiency of reinforcement learning. Some methods use prefixes as rollout conditions or starting states [10], [11], while others emphasize the influence of early reasoning on downstream trajectories [12]–[14]. However, these methods still leave two issues unresolved for reusing teacher prefixes in RL: how to split one long teacher trajectory into multiple valid training states, and how to avoid consuming distilled trajectories as one-shot demonstrations or passive conditions, which underuses the decision information distributed across the trajectory.
Prefix-GRPO addresses this inefficiency by treating trajectory splitting as a way to create differentiated learning queries from a single teacher rollout. Rather than using the whole trajectory as one supervised target, our group-query construction selects informative cut states along the teacher trajectory, so that different prefixes expose different partial progress, remaining subgoals, and recovery opportunities. Each query pairs a teacher prefix that reconstructs an intermediate state with a student continuation optimized by online reward. We further bring the assistant tokens in the teacher prefix into the same clipped policy-optimization form as the continuation tokens, using an SFT-based old-policy estimate for the prefix side. In this way, Prefix-GRPO improves the utilization of distilled trajectories: one teacher trajectory supplies multiple decision-aware training queries, and both sides of each cut contribute to policy learning.
Our main contributions are as follows:
We propose Prefix-GRPO, a reinforcement learning framework for multi-turn agents that jointly learns from replayed teacher prefixes and online continuations, enabling teacher trajectories to be reused beyond one-shot distillation.
We introduce a replayable group-query construction that turns each teacher trajectory into multiple cut-state training queries at different historical depths.
We develop a prompt-space prefix old-logprob anchoring mechanism that enables historical prefix tokens to participate in a clipped GRPO-style objective.
Recent research has re-emphasized the cost, latency, and deployment advantages of small models in agent systems [1]. Recent work on small-model reasoning further shows that controlled exploration and refined offline integration can improve SLM training when distillation is combined with online RL [15]. In parallel, several studies investigate how to transfer tool use, retrieval behavior, and multi-step interaction abilities from large-model agents to smaller students [4]–[6]. These methods usually treat teacher behavior as imitation targets, in-context demonstrations, or reusable agent modules. Our setting also focuses on small-model agents, but the core question is different: we study how a teacher interaction trajectory can be decomposed into prefix queries that can be replayed in the environment, rather than how to compress the teacher’s behavior in one shot.
More broadly, recent studies on graph-aware and structural-data adaptation show that language models often require explicit mechanisms to absorb relational structure, including attention analyses over graph-structured inputs, graph-aware recommendation learning, and structural graph wordification [16]–[18]. This perspective is complementary to our setting, where the structure to be reused comes from temporal interaction histories rather than static graphs.
Another line of work studies result-driven reinforcement learning for language models, especially GRPO- or RLVR-style optimization in mathematics, code, and other verifiable domains [19]–[21]. These methods typically optimize response tokens generated after the current prompt, leaving prompt-history assistant tokens outside the clipped objective because their old-policy log-probabilities are not directly available from online rollout. Recent analysis of asynchronous agentic RL further shows that missing old logits can create semantic mismatch in off-policy correction when the reference policy is not explicit [22]. In parallel, multi-turn agent RL places language models inside observation-action-feedback loops and studies environment interfaces, long-horizon rollout, tool use, and training stability [2], [3], [23]–[27]. Prefix-GRPO inherits the PPO/GRPO-style ratio clipping, but extends the optimization target from continuation tokens to assistant prefix tokens from teacher interaction history.
The most closely related studies use demonstrations, historical prefixes, or off-policy trajectories to improve RL sample efficiency [10], [11], [14]. These methods typically use prefixes as rollout conditions, starting states, or difficulty-control signals, guiding the policy toward local regions that are more likely to yield learning signal. Other work emphasizes that prefixes themselves can strongly influence downstream reasoning paths or optimization stability [12], [28]. Prefix-GRPO shares the view that prefixes are central to learning, but focuses on a different use of trajectory structure: it explicitly splits teacher interaction trajectories into multiple prefix queries that can be replayed in the environment, and treats the assistant tokens inside those prefixes as optimization targets rather than only as conditioning context.
We start from a collection of multi-turn teacher trajectories. In our experiments, these trajectories are generated by MiniMax-M2.1 across the evaluated environments, with each environment instance sampled multiple times to obtain diverse successful interaction traces; the algorithm itself does not depend on this particular teacher. Let \(\tau_i=(h_{i,1},\ldots,h_{i,T_i})\) denote the \(i\)-th teacher trajectory, where each \(h_{i,t}\) is a serialized message or environment-feedback element. Unlike conventional response-only RL, which usually treats each trajectory as a single imitation target or extracts only one cut point, Prefix-GRPO expands one teacher trajectory into multiple cut-state queries and optimizes both the continuation after the cut state and the historical assistant prefix that leads to it.
In this subsection, we describe how Prefix-GRPO derives multiple prefix queries that can be replayed in the environment from each teacher trajectory and turns them into aligned cut-state training samples.
For each trajectory \(\tau_i\), group-query construction selects a set of cut-state queries \(Q_i=\{q_{i,1},\ldots,q_{i,J_i}\}\), where \(J_i\) is the number of retained queries and each query corresponds to a teacher prefix ending immediately after an assistant turn. Figure 2 illustrates the construction. We first score candidate token locations on the serialized teacher trajectory using teacher-forcing entropy under the policy-distilled SFT model. The score is restricted to assistant interaction tokens, smoothed with a centered window, and converted into an entropy-change signal. High-change tokens are then mapped back to their assistant turns, so each selected token induces a cut point after the corresponding assistant action. In the example, the top-ranked entropy-change tokens produce three cut-state queries at different historical depths; each query becomes a prompt of the form system instruction, prefix history, and cut-state observation. We keep up to three distinct prefix queries per trajectory, together with one raw no-prefix query. Exact scoring, deduplication, and top-\(k\) rules are given in Appendix 6.2.0.1.
Each selected query is replayed in the environment before it is admitted into training. In TextCraft, replay starts from an environment created with the sample’s task identifier and goal, executes the teacher prefix actions sequentially, and keeps the query only if the replayed observations match the continuation-side observations on shared structured fields. Queries marked mismatch, unverifiable, or error are discarded rather than repaired.
After replay, the training prompt is canonicalized as \[\label{eq:canonical-prompt} x_i=\mathrm{concat}(\text{system}, \text{prefix history}, \text{cut-state user observation}).\tag{1}\] This canonical form makes the prompt end at the replayed cut-state observation rather than at the last teacher action, ensuring that student rollout starts from an environment-consistent state. Each replay-validated query is then treated as an independent training sample; for notational simplicity, we re-index these samples by \(i\) below.
In this subsection, we describe how Prefix-GRPO computes old log-probabilities for distilled prefix tokens in the canonicalized prompt space.
Continuation tokens are sampled by the online rollout policy, so their old log-probabilities are available in the standard GRPO buffer. Prefix tokens are different: they are teacher-derived assistant tokens already embedded in the prompt history. To place them under the same clipped-ratio training form, we use the policy-distilled SFT checkpoint as a fixed old policy for prefixes and recompute teacher-forcing log-probabilities on the canonicalized prompt. Concretely, each replay-validated sample stores three prompt-space annotations: (i) an assistant-prefix span \([b_i,e_i)\), (ii) a binary prefix mask \(m_i\) over that span, and (iii) cached old log-probabilities \(\ell_{i,u}^{\mathrm{old}}\) stored densely over the same span. The span localizes the replayed prefix window, while the mask specifies which positions inside that window should receive prefix loss. This is necessary because the window is defined in prompt-token coordinates and may contain boundary, formatting, or non-optimized tokens; the objective should update only the historical assistant tokens selected for prefix learning. The valid prefix-token set is therefore \[\label{eq:prefix-mask-set} M_i^{\mathrm{pre}}=\{u\mid b_i\le u<e_i,\; m_i[u-b_i]=1\}.\tag{2}\] This representation is deliberately prompt-space rather than turn-space: after canonicalization, the prefix tokens may lie in the middle of the prompt, and the span-mask-logprob annotations provide the coordinates needed to gather them during training. More detail is given in Appendix 6.2.0.4.
In this subsection, we describe how Prefix-GRPO writes continuation learning and prefix learning in a unified clipped-ratio form.
Prefix-GRPO optimizes two token groups in the same policy update. The continuation group contains tokens generated by the student after the replayed cut state and is trained with environment reward. The prefix group contains historical assistant tokens from the replayed teacher prefix and is trained with the cached prompt-space old log-probabilities described above. The two groups differ in where their tokens come from and how their old log-probabilities are obtained, but both are optimized by the same clipped surrogate.
Let \(M_i^{\mathrm{cont}}\) be the set of valid continuation tokens and let \(\hat{A}_{i,t}^{\mathrm{cont}}\) denote the token-level continuation advantage, obtained by broadcasting the sequence/group-level advantage to valid continuation positions. The continuation loss is \[\label{eq:cont-loss} \mathcal{L}_{\mathrm{cont}} =-\sum_{t\in M_i^{\mathrm{cont}}} \min\left( r_{i,t}^{\mathrm{cont}}\hat{A}_{i,t}^{\mathrm{cont}}, \mathrm{clip}(r_{i,t}^{\mathrm{cont}},1-\epsilon,1+\epsilon)\hat{A}_{i,t}^{\mathrm{cont}} \right).\tag{3}\] This branch is close to standard response-only GRPO. The main difference is not the surrogate form itself, but the fact that rollout starts from a replayed intermediate state rather than from the environment’s initial state.
For any valid prefix position \(u\in M_i^{\mathrm{pre}}\), the prefix importance ratio is \[\label{eq:prefix-ratio} r_{i,u}^{\mathrm{pre}} =\exp\left( \log \pi_\theta(z_{i,u}\mid x_i,z_{i,<u})-\ell_{i,u}^{\mathrm{old}} \right).\tag{4}\] For continuation positions, \(r_{i,t}^{\mathrm{cont}}\) is defined analogously with the rollout old policy. Both token groups are then optimized by clipped policy-ratio terms. The continuation term uses the group-relative advantage \(\hat{A}_{i,t}^{\mathrm{cont}}\) from online rollout. For the prefix group, Prefix-GRPO supports several choices of \(\hat{A}_i^{\mathrm{pre}}\); our main TextCraft configuration uses the continuation-magnitude anchor: \[\label{eq:prefix-adv} \hat{A}_i^{\mathrm{pre}} =\left| \frac{\sum_t \hat{A}_{i,t}^{\mathrm{cont}} m_{i,t}^{\mathrm{cont}}}{\sum_t m_{i,t}^{\mathrm{cont}}} \right|,\tag{5}\] where \(m_{i,t}^{\mathrm{cont}}\) is the valid continuation-token mask. For compactness, define \[g(r,A;\epsilon^-,\epsilon^+) =\min\!\left(rA,\mathrm{clip}(r,1-\epsilon^-,1+\epsilon^+)A\right).\] The complete training objective is \[\label{eq:full-loss} \begin{align} \mathcal{L} =&-\sum_{t\in M_i^{\mathrm{cont}}} g(r_{i,t}^{\mathrm{cont}},\hat{A}_{i,t}^{\mathrm{cont}};\epsilon,\epsilon) \\ &-\lambda_{\mathrm{pre}}\sum_{u\in M_i^{\mathrm{pre}}} g(r_{i,u}^{\mathrm{pre}},\hat{A}_i^{\mathrm{pre}}; \epsilon_{\mathrm{pre}}^{-},\epsilon_{\mathrm{pre}}^{+}). \end{align}\tag{6}\] This form puts prefix learning and continuation learning under the same clipped surrogate, while keeping their loss terms, old-policy sources, and advantage assignments separate. It should not be interpreted as assigning signed credit to the replayed teacher prefix. Signed credit remains in the continuation term, while the prefix term uses the magnitude of the continuation learning signal to control how strongly replay-validated teacher prefixes are anchored. The coefficient \(\lambda_{\mathrm{pre}}\) controls the strength of prefix optimization. The main experiments use the split objective shown above, while joint-objective variants are studied as ablations. Additional objective sensitivities are reported in Appendix 8.1.
We evaluate on three long-horizon interactive environments: TextCraft for symbolic crafting [29], ALFWorld for household instruction following [30], and BabyAI for grid-world compositional instruction execution [31]. Together, these environments cover symbolic planning, grounded instruction following, and long-horizon action execution, allowing us to evaluate whether Prefix-GRPO improves small-model agents across different forms of multi-turn decision making.
We compare five method families: the raw Base Model, SFT as direct trajectory distillation, RL recipes from the base model (GRPO, GRPO-MIS, DAPO) [19], [20], the same RL recipes from an SFT-initialized policy, and Prefix-Based RL, which includes Replay-GRPO and Prefix-GRPO. The key contrast is whether teacher prefixes are ignored, replayed only, or replayed and explicitly optimized.
Each environment uses its official task-family split and action interface. We keep the evaluation budget fixed at eight sampled rollouts per task and report both Avg@8 and Pass@8. Detailed prompt formats, SFT configurations,
rollout limits, and Prefix-GRPO training settings for each environment are provided in Appendix 7.
All experiments use Qwen3-1.7B as the base policy. For each task, we sample eight rollouts and report two task-family metrics: Avg@8, the average success rate across the eight rollouts, and Pass@8, whether at least one rollout
succeeds. Avg@8 reflects rollout reliability, while Pass@8 measures whether repeated sampling can recover a successful trajectory.
| Method | Depth1 | Depth2 | Depth3 | Depth4 | Overall | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2-3(lr)4-5(lr)6-7(lr)8-9(l)10-11 | Avg@8 | Pass@8 | Avg@8 | Pass@8 | Avg@8 | Pass@8 | Avg@8 | Pass@8 | Avg@8 | Pass@8 | ||||||||||||||||||||
| Base Model | 79.03 | 90.32 | 21.95 | 41.46 | 1.50 | 8.33 | 0.00 | 0.00 | 33.87 | 47.47 | ||||||||||||||||||||
| SFT | 99.60 | 100.00 | 96.65 | 100.00 | 53.50 | 76.00 | 0.00 | 0.00 | 83.87 | 91.00 | ||||||||||||||||||||
| GRPO | 99.60 | 100.00 | 71.91 | 97.50 | 18.00 | 48.00 | 0.00 | 0.00 | 64.86 | 82.83 | ||||||||||||||||||||
| GRPO-MIS | 93.55 | 96.77 | 64.02 | 90.24 | 1.00 | 4.17 | 0.00 | 0.00 | 55.50 | 68.69 | ||||||||||||||||||||
| DAPO | 99.60 | 100.00 | 78.01 | 97.50 | 14.14 | 33.33 | 0.00 | 0.00 | 66.39 | 79.59 | ||||||||||||||||||||
| SFT\(\rightarrow\)GRPO | 100.00 | 100.00 | 97.87 | 100.00 | 62.00 | 88.00 | 0.00 | 0.00 | 86.62 | 93.88 | ||||||||||||||||||||
| SFT\(\rightarrow\)GRPO-MIS | 99.60 | 100.00 | 99.09 | 100.00 | 59.26 | 73.91 | 0.00 | 0.00 | 86.32 | 90.72 | ||||||||||||||||||||
| SFT\(\rightarrow\)DAPO | 99.60 | 100.00 | 98.48 | 100.00 | 67.00 | 92.00 | 4.17 | 33.33 | 88.12 | 95.96 | ||||||||||||||||||||
| Replay-GRPO | 99.19 | 100.00 | 80.49 | 95.12 | 10.00 | 36.00 | 0.00 | 0.00 | 66.25 | 78.79 | ||||||||||||||||||||
| Prefix-GRPO | 99.60 | 100.00 | 92.99 | 100.00 | 50.00 | 92.00 | 4.17 | 33.33 | 81.63 | 96.00 | ||||||||||||||||||||
3pt
Table 1 shows that TextCraft mainly stresses multi-step subgoal maintenance. The base policy already solves many depth-1 tasks, but performance drops sharply as recipe depth increases. SFT greatly improves both
metrics, and RL from the SFT model is consistently stronger than RL from the base policy. Among prefix-based methods, replay alone is weaker than the strongest SFT-initialized RL baselines, whereas Prefix-GRPO achieves the best overall Pass@8
and matches the strongest depth-4 result. This suggests that explicit prefix optimization is most useful for recovering successful continuations from difficult intermediate states, while strong SFT-initialized RL remains competitive in average rollout
quality.
2pt
@l*12c@ & & & & & &
(lr)2-3(lr)4-5(lr)6-7(lr)8-9(lr)10-11(l)12-13 & Avg@8 & Pass@8 & Avg@8 & Pass@8 &
Avg@8 & Pass@8 & Avg@8 & Pass@8 & Avg@8 & Pass@8 & Avg@8 & Pass@8
Base Model & 65.07 & 100.00 & 40.40 & 73.33 & 66.74 & 100.00 & 35.70 & 60.00 & 34.52 & 80.00 & 58.75 & 90.00
SFT & 91.14 & 98.18 & 83.33 & 100.00 & 85.00 & 100.00 & 56.25 & 100.00 & 70.00 & 80.00 & 84.44 & 97.78
GRPO & 92.33 & 100.00 & 86.09 & 100.00 & 96.45 & 100.00 & 73.39 & 80.00 & 66.09 & 80.00 & 93.47 & 96.67
GRPO-MIS & 99.55 & 100.00 & 91.67 & 100.00 & 97.50 & 100.00 & 73.75 & 80.00 & 65.00 & 80.00 & 93.33 & 96.67
DAPO & 99.09 & 100.00 & 93.33 & 100.00 & 100.00 & 100.00 & 78.75 & 80.00 & 80.00 & 80.00 & 94.86 & 96.67
SFT\(\rightarrow\)GRPO & 99.09 & 100.00 & 100.00 & 100.00 & 100.00 & 100.00 & 67.50 & 80.00 & 82.50 & 100.00 & 94.86 & 97.78
SFT\(\rightarrow\)GRPO-MIS & 97.95 & 100.00 & 94.17 & 100.00 & 97.50 & 100.00 & 73.75 & 80.00 & 90.00 & 100.00 & 94.17 & 97.78
SFT\(\rightarrow\)DAPO & 98.18 & 100.00 & 98.33 & 100.00 & 97.50 & 100.00 & 67.50 & 90.00 & 87.50 & 100.00 & 94.17 & 98.89
Replay-GRPO & 98.18 & 100.00 & 92.50 & 100.00 & 100.00 & 100.00 & 68.75 & 80.00 & 77.50 & 100.00 & 92.92 & 97.78
Prefix-GRPO & 99.09 & 100.00 & 92.50 & 100.00 & 100.00 & 100.00 & 73.75 & 80.00 & 82.50 & 100.00 & 94.31 & 100.00
Table ¿tbl:tab:babyai95tasks? shows a shorter-horizon instruction-following regime where many methods already achieve high best-of-eight success. The base policy obtains strong Pass@8 on GoTo and AOD, but its
Avg@8 remains weak on Pickup, Find Room, and SLoc, indicating unstable single-rollout execution. Distillation and RL both improve this average behavior: DAPO and SFT\(\rightarrow\)GRPO reach the strongest
overall Avg@8, while Prefix-GRPO attains the best overall Pass@8. Compared with Replay-GRPO, explicit prefix optimization raises overall Avg@8 from 92.92 to 94.31 and Pass@8 from 97.78 to 100.00, with the
clearest gains on Find Room and SLoc. Thus, BabyAI does not show the same large separation as TextCraft, but it still supports the reliability benefit of prefix optimization under multi-sample evaluation.
2pt
@l*14c@ & & & & & & &
(lr)2-3(lr)4-5(lr)6-7(lr)8-9(lr)10-11(lr)12-13(l)14-15 & Avg@8 & Pass@8 & Avg@8 &
Pass@8 & Avg@8 & Pass@8 & Avg@8 & Pass@8 & Avg@8 & Pass@8 & Avg@8 &
Pass@8 & Avg@8 & Pass@8
Base Model & 57.61 & 84.78 & 19.59 & 59.46 & 6.39 & 28.89 & 11.16 & 32.14 & 13.00 & 44.00 & 21.71 & 63.16 & 23.56 & 53.00
SFT & 63.59 & 89.13 & 30.74 & 72.97 & 25.00 & 66.67 & 33.48 & 71.43 & 16.50 & 56.00 & 61.84 & 100.00 & 38.56 & 75.50
GRPO & 85.09 & 94.59 & 73.21 & 89.29 & 37.51 & 82.50 & 59.50 & 80.95 & 61.17 & 81.25 & 63.38 & 93.75 & 63.55 & 87.34
GRPO-MIS & 88.32 & 97.83 & 74.66 & 89.19 & 49.72 & 93.33 & 53.57 & 78.57 & 44.50 & 88.00 & 78.29 & 100.00 & 65.81 & 91.50
DAPO & 88.86 & 97.83 & 74.32 & 86.49 & 46.67 & 88.89 & 47.32 & 75.00 & 40.00 & 84.00 & 84.21 & 100.00 & 64.31 & 89.00
SFT\(\rightarrow\)GRPO & 94.84 & 97.83 & 75.00 & 89.19 & 51.94 & 86.67 & 75.00 & 86.67 & 67.50 & 88.00 & 84.21 & 100.00 & 74.31 & 90.50
SFT\(\rightarrow\)GRPO-MIS & 92.93 & 100.00 & 81.76 & 97.30 & 61.11 & 88.89 & 72.77 & 89.29 & 60.00 & 84.00 & 90.13 & 100.00 & 76.50 & 93.50
SFT\(\rightarrow\)DAPO & 93.75 & 100.00 & 74.66 & 91.89 & 49.72 & 86.67 & 65.18 & 92.86 & 51.50 & 84.00 & 90.79 & 100.00 & 70.75 & 92.50
Replay-GRPO & 82.88 & 95.45 & 58.11 & 81.08 & 23.61 & 68.89 & 37.50 & 67.86 & 52.50 & 84.00 & 59.87 & 78.95 & 52.62 & 80.00
Prefix-GRPO & 92.12 & 100.00 & 78.38 & 89.19 & 44.17 & 95.56 & 59.82 & 89.29 & 70.50 & 92.00 & 78.95 & 100.00 & 70.31 & 94.50
Table ¿tbl:tab:alfworld95tasks? shows that ALFWorld is substantially harder than BabyAI. The base policy obtains non-trivial Pass@8 on Simple Place and Examine, but average success remains low on multi-step manipulation
families. SFT improves both overall metrics, and RL from the base model gives a much larger gain: GRPO, GRPO-MIS, and DAPO all improve overall Pass@8 from 53.00 to roughly 87–92. SFT-initialized RL further improves average rollout reliability,
with SFT\(\rightarrow\)GRPO-MIS achieving the best overall Avg@8. Prefix-GRPO, however, obtains the best overall Pass@8 and substantially improves over Replay-GRPO, raising Avg@8 from
52.62 to 70.31 and Pass@8 from 80.00 to 94.50. The gains are most visible in best-of-eight recovery on Two-Obj Place and Heat Place. This pattern is consistent with TextCraft and BabyAI: explicit prefix optimization improves recovery from
teacher-derived intermediate states, while the strongest SFT-initialized RL baselines can remain more reliable on average rollout success.
Overall, the task-family results show that the three environments stress different failure modes: symbolic subgoal maintenance in TextCraft, grounded instruction execution in BabyAI, and long-horizon household manipulation in ALFWorld. Across all three
environments, Prefix-GRPO achieves the strongest overall Pass@8, but it does not always achieve the strongest overall Avg@8. This separates two effects: explicit prefix optimization improves multi-sample recovery from useful
teacher-derived states, while strong SFT-initialized RL baselines can remain more reliable on average rollout success. The consistent gap between Replay-GRPO and Prefix-GRPO further indicates that teacher prefixes are more useful when they are directly
optimized rather than only replayed as context.
The effectiveness of Prefix-GRPO depends on which intermediate states are exposed to the student. Table 2 compares four construction families on TextCraft. Fixed-ratio strategies split each teacher trajectory at manually chosen relative depths, while entropy-based strategies select cut points according to uncertainty patterns under the policy-distilled SFT model. The proposed Entropy-Change Top-3 construction performs best across all reported TextCraft metrics. Its advantage over Raw-Entropy Top-3 suggests that the most useful cut points are not necessarily the positions with the highest uncertainty, but the positions where the model’s uncertainty changes sharply after smoothing.
| Construction | Avg@1 | Pass@2 | Pass@4 | Pass@8 |
|---|---|---|---|---|
| Fixed-Ratio (0.1/0.3/0.5) | 75.82 | 83.02 | 88.74 | 93.75 |
| Fixed-Ratio (0.25/0.5/0.7) | 80.02 | 87.32 | 92.10 | 94.79 |
| Raw-Entropy Top-3 | 78.07 | 85.60 | 89.20 | 90.82 |
| Entropy-Change Top-3 | 81.63 | 88.18 | 92.71 | 96.00 |
7pt
This ablation separates the effect of replaying teacher prefixes from the effect of applying policy-gradient updates to the prefix tokens themselves. Table 3 compares a replay-only variant
with the full Prefix-GRPO objective under the same TextCraft data, rollout budget, optimization budget, and evaluation protocol. In the replay-only variant, teacher prefixes are used to reach recovered intermediate states and are included in the prompt
context, but the policy loss is applied only to continuation tokens. Replay-only training exposes the policy to teacher-recovered intermediate states, but it remains substantially below full Prefix-GRPO; the largest gap appears at Pass@8,
where explicit prefix optimization improves performance from 78.79 to 96.00. These results indicate that teacher prefixes should not only be replayed as context, but also receive direct policy updates.
| Method | Avg@1 | Pass@2 | Pass@4 | Pass@8 |
|---|---|---|---|---|
| Replay only, no prefix-token loss | 66.25 | 71.39 | 75.20 | 78.79 |
| Prefix-GRPO with SFT old-logprob anchor | 81.63 | 88.18 | 92.71 | 96.00 |
7pt
Table 4 studies two related design choices for using teacher prefixes:
Prefix advantage assignment keeps the same group-query data but changes how prefix-token updates are weighted. Besides constant weighting and positive-only continuation signals, we test success-gated updates, family lift over the raw query, and the main continuation-magnitude anchor.
Full-demo query reuse adds the complete teacher trajectory as an additional group-query member, with SFT-computed old log-probabilities and \(\mathrm{clamp}(R_{\mathrm{demo}}-\bar{R}_{\mathrm{raw}},0,1)\) as its demo advantage.
Here success-gated updates apply prefix loss only when the continuation succeeds, while family lift compares each prefix query against the raw no-prefix query from the same teacher trajectory. Full definitions are given in Appendix 8.1.0.1. The full-demo query improves low-budget metrics, but the continuation-magnitude anchor gives the best Pass@4 and Pass@8, suggesting that prefix updates are most useful when
their strength is tied to the downstream continuation signal.
| Variant | Avg@1 | Pass@2 | Pass@4 | Pass@8 |
|---|---|---|---|---|
| Constant prefix weight | 70.84 | 80.40 | 87.00 | 90.70 |
| Positive continuation signal | 76.25 | 85.00 | 91.07 | 93.94 |
| Success-gated prefix update | 76.54 | 83.49 | 88.53 | 91.84 |
| Family lift over raw query | 74.62 | 81.54 | 86.59 | 89.80 |
| Continuation-magnitude anchor (main) | 81.63 | 88.18 | 92.71 | 96.00 |
| Full-trajectory demo query | 83.21 | 88.49 | 92.03 | 94.85 |
5pt
Beyond the choice of cut states and prefix-side signals, Prefix-GRPO also depends on how prefix and continuation losses are combined. Table 5 compares the main split objective with a joint-objective variant and a weaker prefix-loss weight. The split objective with unit prefix weight performs best across all reported metrics, while the joint variant is substantially weaker. This suggests that prefix and continuation tokens benefit from sharing the same clipped-ratio form, but should retain separate loss terms and weighting. Additional prefix-clip sensitivity is reported in Appendix 8.1.
| Loss combination | \(\lambda_{\mathrm{pre}}\) | Avg@1 | Pass@2 | Pass@4 | Pass@8 |
|---|---|---|---|---|---|
| Joint objective | 1.0 | 74.75 | 82.43 | 86.33 | 89.00 |
| Split objective (main) | 1.0 | 81.63 | 88.18 | 92.71 | 96.00 |
| Split objective | 0.5 | 78.61 | 86.18 | 90.96 | 93.88 |
6pt
The previous ablations evaluate final task success. To verify that the prefix branch is also active during optimization, Table 6 reports prefix-side diagnostics averaged over the last 100
optimizer steps. Across construction variants, the prefix KL remains non-zero while the prefix clip fraction stays low, indicating that assistant prefix tokens receive controlled updates under the SFT old-policy anchor rather than being either ignored or
destabilized. The loss share and token fraction further show that the prefix branch contributes a small but persistent part of the update, instead of dominating the continuation objective. Entropy-Change Top-3 also combines a moderate prefix loss share
with the strongest Pass@8, suggesting that the best construction rule is not simply the one with the largest prefix update, but the one that yields useful and stable prefix-side learning signals.
| Construction | Prefix KL | Clip Frac. | Loss Share | Token Frac. | Pass@8 |
|---|---|---|---|---|---|
| Fixed-Ratio 0.1/0.3/0.5 | 1.067 | 0.0163 | 0.0900 | 0.341 | 93.75 |
| Fixed-Ratio 0.25/0.5/0.7 | 1.242 | 0.0089 | 0.0618 | 0.399 | 94.79 |
| Raw-Entropy Top-3 | 1.409 | 0.0084 | 0.0518 | 0.401 | 90.82 |
| Entropy-Change Top-3 | 1.319 | 0.0101 | 0.0696 | 0.392 | 96.00 |
6pt
In this paper, we introduced Prefix-GRPO, a reinforcement learning framework that turns teacher-trajectory prefixes into explicit optimization targets rather than treating them as passive context. Our method combines group-query prefix construction with prompt-space prefix old-logprob anchoring, allowing a single teacher trajectory to produce multiple replay-aligned training states and enabling historical prefix tokens to participate directly in GRPO optimization. Across TextCraft, BabyAI, and ALFWorld, the experiments show that small-model agents benefit from combining distillation with reinforcement learning, while the TextCraft ablations provide the clearest evidence for the role of prefix optimization: replaying teacher prefixes alone is not sufficient, and directly optimizing prefix tokens improves multi-sample recovery on harder tasks.
Several limitations remain: most results are single-run experiments, Prefix-GRPO requires replay-verifiable teacher prefixes, and the SFT old-policy anchor still needs more systematic study. Future work should extend matched ablations across more environments and analyze alternative prefix-side objectives and old-policy anchors.
Supplementary Material for
Replayed Prefix Optimization for Small-Model Agents
A Datasets to 0.6em.
A.1 Dataset Overview to 0.6em.
A.2 Prefix-GRPO Data Construction to 0.6em.
A.3 Mask Alignment Example to 0.6em.
B Implementation Details in Each Environment to 0.6em.
B.1 TextCraft to 0.6em.
B.2 BabyAI to 0.6em.
B.3 ALFWorld to 0.6em.
B.4 Prompt Templates to 0.6em.
C Additional Experimental Results to 0.6em.
C.1 Additional TextCraft Objective Ablations to 0.6em.
C.2 BabyAI Construction Ablation to 0.6em.
D Behavior Diagnostics and Case Studies to 0.6em.
D.1 Training Dynamics to 0.6em.
D.2 Evaluation Diagnostics to 0.6em.
D.3 Failure-Mode Diagnostics to 0.6em.
D.4 Rollout Visualization to 0.6em.
Table ¿tbl:tab:dataset95statistics? summarizes the task-family splits used for GRPO training, prefix fullflow training, and evaluation in the three retained environments. We then describe how teacher trajectories are converted into replay-validated Prefix-GRPO training samples.
2pt
Prefix-GRPO first turns teacher interaction trajectories into replay-validated training states before online reinforcement learning begins. The data construction pipeline consists of five stages: collecting teacher trajectories, constructing group-query prefixes, validating each prefix by environment replay, canonicalizing the prompt at the cut state, and estimating old log-probabilities for historical prefix tokens. The resulting corpus stores both the textual prompt and the sidecar fields needed by the Prefix-GRPO objective.
Let \((x_1,\ldots,x_T)\) denote the token sequence of a fully serialized teacher trajectory. We use the same policy-distilled SFT checkpoint that later serves as the prefix old policy to compute teacher-forcing
next-token entropy: \[\label{eq:entropy}
H_t=-\sum_v p_\phi(v\mid x_{<t})\log p_\phi(v\mid x_{<t}).\tag{7}\] In the main TextCraft pipeline, scoring is restricted to the interaction_assistant token domain. After filtering to this domain and sorting by original
token position, we smooth the entropy sequence with a centered moving average. The main experiments use \(w=11\) as the main instantiation rather than as a sensitivity-tuned optimum. Let \(\hat{H}_j\) denote the smoothed entropy on the filtered sequence. The entropy-change score is then \[\label{eq:entropy-change}
s_j=\left|\hat{H}_j-\hat{H}_{j-1}\right|.\tag{8}\] Candidate tokens are ranked globally by \(s_j\), mapped to assistant turns, deduplicated within each assistant turn, and truncated to at most top-\(k=3\) distinct assistant turns. If multiple high-scoring tokens map to the same assistant turn, only the highest-scoring token is kept for that turn. We impose no minimum temporal gap across selected turns; if fewer than three
distinct assistant turns are available, the trajectory contributes fewer prefix queries. In addition to these prefix queries, we keep one raw no-prefix query for the same teacher trajectory. We use \(k=3\) as the main
instantiation to expose multiple cut states while keeping dataset expansion manageable, rather than claiming it as a sensitivity-tuned optimum.
Replay validation is stricter than checking whether prefix actions are merely executable. For each candidate prefix query, we create a TextCraft environment using the sample’s task identifier and goal, replay the teacher prefix actions in order, and
compare the replayed observation against the first continuation-side user observation. If the continuation still contains another assistant action, we additionally execute that action as a one-step probe and compare the next observation as well. Matching
is performed on shared structured fields extracted from the observations, including Inventory:, Got ..., and Crafted ....
Table 7 compares replay validation quality with downstream TextCraft performance across construction families. Replay validation provides a data-quality floor, but the downstream
result is not monotonic in the validated-prefix ratio: Raw-Entropy Top-3 has the highest validation rate, whereas Entropy-Change Top-3 gives the strongest Pass@8.
| Construction | Candidates | Validated | Trainable | Val. Rate | Train. Rate | Pass@8 |
|---|---|---|---|---|---|---|
| Fixed-Ratio 0.1/0.3/0.5 | 4488 | 3620 | 4017 | 80.66 | 89.50 | 93.75 |
| Fixed-Ratio 0.25/0.5/0.7 | 4488 | 3745 | 4131 | 83.45 | 92.05 | 94.79 |
| Raw-Entropy Top-3 | 4399 | 3743 | 3743 | 85.09 | 85.09 | 90.82 |
| Entropy-Change Top-3 | 4399 | 3694 | 3694 | 83.98 | 83.98 | 96.00 |
2pt
Suppose a selected cut point falls after assistant turn \(k\). Then prefix_messages contain all messages up to and including that assistant message, while continuation_messages begin from the
following user observation. After replay validation, the training prompt is canonicalized as \[\label{eq:canonical-prompt-app}
x_i=\mathrm{concat}(\text{system},\text{prefix history},\text{cut-state user observation}).\tag{9}\] The prompt therefore ends at the replayed user-side observation rather than at the teacher action itself.
Continuation tokens are produced by the online rollout and therefore naturally come with old log-probabilities from the rollout policy. Prefix tokens are different: they are teacher-derived assistant tokens already located inside the prompt history, not
tokens sampled by the current online rollout. To support PPO/GRPO-style optimization on these tokens, we use a policy-distilled SFT checkpoint as the prefix old policy. For each canonicalized prompt \(x_i\), we run teacher
forcing under the SFT old policy and save the prefix sidecar \[\label{eq:prefix-sidecar-app}
\mathcal{S}_i=(b_i,e_i,m_i,\ell_i^{\mathrm{old}},n_i),\tag{10}\] where \([b_i,e_i)\) is the prefix span, \(m_i\) is the prefix mask, \(\ell_i^{\mathrm{old}}\) are cached old log-probabilities stored densely over the span, and \(n_i=\sum_u m_i[u-b_i]\) is the prefix token count. The valid prefix-token positions are
\[\label{eq:prefix-mask-set-app}
M_i^{\mathrm{pre}}=\{u\mid b_i\le u<e_i,\; m_i[u-b_i]=1\}.\tag{11}\] We additionally verify that prefix_token_count equals prefix_mask.sum() and that both prefix_mask and
assistant_prefix_old_log_probs have length \(e_i-b_i\).
Tables 8 and 9 give a concrete replay-validated TextCraft example. The key point is that span, mask, and old log-probabilities are all generated after prompt canonicalization and therefore share the same prompt-token coordinate system.
| Field | Value |
|---|---|
| Task | task_id=100, goal: warped planks |
| Prefix strategy | Entropy-Change Top-3 over interaction assistant tokens (\(w=11\)) |
| Canonicalized messages | system, goal, assistant, user observation, assistant, cut-state user observation |
| Assistant prefix span | \([782,946)\); span length \(=164\) |
| Prefix mask / old log-probs | \(|m_i|=164\), \(\sum m_i=143\), \(|\ell_i^{\mathrm{old}}|=164\) |
| Training gather rule | gather only positions with \(m_i[u-b_i]=1\) |
4pt
| Token region | Example | Mask behavior |
|---|---|---|
| First assistant reasoning/action | Think: The user wants... Action: [[ craft 4 warped planks using 1 warped stems ]] | mask \(=1\) |
| Intervening user observation | Could not find enough items... | mask \(=0\) |
| Second assistant reasoning/action | Think: The player is telling... Action: [[ get 1 warped stems ]] | mask \(=1\) |
| Cut-state observation | Got 1 warped stems | outside the prefix span |
3pt
This example shows that changes in system or observation tokens do not require reusing stale turn-level offsets: the sidecar is regenerated on the final canonicalized prompt, and prefix loss is applied only to mask-one assistant positions.
We describe the environment-specific task setup, evaluation protocol, and training configuration below.
All main experiments were run on 2 NVIDIA H200 GPUs. Under this setup, an SFT run typically took about 1–3 hours, while an RL training run took approximately 1–2 days depending on the environment and ablation setting. Evaluation used the corresponding trained checkpoint with a fixed eight-rollout sampling budget per task.
TextCraft is the primary environment used to validate the full Prefix-GRPO pipeline. The agent observes a symbolic crafting task and interacts through textual actions such as inventory inspection, acquiring primitive items, and crafting target objects from recipes. A trajectory is successful only when the target object is actually produced in the environment; merely emitting a completion phrase is not sufficient.
TextCraft uses a fixed system prompt followed by a dynamic task observation. Prefix rows additionally include the canonicalized prefix history up to the cut state. The prompt template is listed in Appendix 7.4.
TextCraft uses the full Prefix-GRPO pipeline, including replay validation, prefix old-logprob recomputation, and online rollout from recovered cut states. Table 10 lists the main RL training settings; the SFT stage uses 20 epochs and learning rate \(1\times 10^{-5}\).
| Parameter | Value | Parameter | Value |
|---|---|---|---|
| GPUs | 2 | Gradient checkpointing | disabled |
| Train batch size | 16 | PPO mini-batch size | 16 |
| PPO epochs | 2 | Micro batch/GPU | 8 |
| Learning rate | \(5\times 10^{-6}\) | KL loss | disabled |
| Rollout \(n\) | 8 | Temperature / top-\(p\) | 1.0 / 1.0 |
| Max prompt length | 2048 | Max response length | 8192 |
| Rollout prompt length | 2048 | Rollout response length | 8192 |
| Rollout max tokens | 512 | Max model length | 12288 |
| Max batched tokens | 8192 | Max num seqs | 256 |
| Max assistant turns | 30 | Max user turns | 30 |
| Prefix loss mode | split | Prefix loss weight | 1.0 |
| Prefix advantage mode | cont_mean_abs | Prefix clip low / high | 0.2 / 0.2 |
6pt
TextCraft training requires an environment server, a rollout backend, replay validation, and old-logprob recomputation. The main additional preprocessing cost of Prefix-GRPO comes from replay validation and prompt-space teacher forcing under the SFT old policy. These costs are incurred before RL training and are amortized across subsequent policy updates.
BabyAI evaluates grounded instruction following in grid-world tasks. The agent receives a natural-language instruction and must execute a sequence of actions that satisfies the instruction in the environment. The main paper reports Avg@8
and Pass@8 by official task family and also keeps the overall success rate for supplementary comparison.
BabyAI uses a thought-action-observation prompt with an explicit action format and the currently available action set. The prompt template is listed in Appendix 7.4.
Table 11 lists the BabyAI RL settings, with rollout limits adapted to the grid-world interaction format. The SFT stage uses 20 epochs and learning rate \(1\times 10^{-5}\).
| Parameter | Value | Parameter | Value |
|---|---|---|---|
| GPUs | 2 | Gradient checkpointing | disabled |
| Train batch size | 16 | PPO mini-batch size | 16 |
| PPO epochs | 2 | Micro batch/GPU | 8 |
| Learning rate | \(5\times 10^{-6}\) | KL loss | disabled |
| Rollout \(n\) | 8 | Temperature / top-\(p\) | 1.0 / 1.0 |
| Max prompt length | 1024 | Max response length | 4096 |
| Rollout prompt length | 8192 | Rollout response length | 4096 |
| Rollout max tokens | 512 | Max model length | 8192 |
| Max batched tokens | 8192 | Max num seqs | 128 |
| Max assistant turns | 15 | Max user turns | 16 |
| Prefix loss mode | split | Prefix loss weight | 1.0 |
| Prefix advantage mode | cont_mean_abs | Prefix clip low / high | 0.2 / 0.2 |
6pt
ALFWorld evaluates text-based household instruction following with grounded task structure. The agent must interpret a household goal, issue valid textual actions, and reach the required terminal state. In the main paper, results are reported by
official task family using Avg@8 and Pass@8, which exposes whether gains are concentrated on short placement tasks or extend to harder multi-step tasks.
ALFWorld uses a household-task system prompt, a fixed user message, and environment observations from reset and step outputs. The prompt template is listed in Appendix 7.4.
Table 12 lists the ALFWorld RL settings, including the longer context budget used for household trajectories. The SFT stage uses 20 epochs and learning rate \(1\times 10^{-5}\).
| Parameter | Value | Parameter | Value |
|---|---|---|---|
| GPUs | 2 | Gradient checkpointing | disabled |
| Train batch size | 16 | PPO mini-batch size | 16 |
| PPO epochs | 2 | Micro batch/GPU | 8 |
| Learning rate | \(5\times 10^{-6}\) | KL loss | disabled |
| Rollout \(n\) | 8 | Temperature / top-\(p\) | 1.0 / 1.0 |
| Max prompt length | 1024 | Max response length | 4096 |
| Rollout prompt length | 8192 | Rollout response length | 4096 |
| Rollout max tokens | 384 | Max model length | 12288 |
| Max batched tokens | 12288 | Max num seqs | 256 |
| Max assistant turns | 15 | Max user turns | 16 |
| Prefix loss mode | split | Prefix loss weight | 1.0 |
| Prefix advantage mode | cont_mean_abs | Prefix clip low / high | 0.2 / 0.2 |
6pt
We collect the full prompt templates in one place to avoid interrupting the environment-specific configuration sections with long verbatim blocks. The serialized training prompts additionally include dataset-specific prefix histories and cut-state observations.
TextCraft.
You are a Minecraft Assistant. Your goal is to craft items by managing resources and recipes.
CORE PROTOCOL:
1. THINK FIRST: before any action, analyze the current state.
2. ONE ACTION: output exactly one action per turn.
3. BOX FORMAT: wrap your command in [[ ]], e.g., Action: [[ inventory ]]
4. NO HALLUCINATION: do not simulate the environment response.
REASONING LOGIC:
When trying to acquire an item [Target]:
1. Check inventory. If you already have [Target], proceed.
2. Check recipe. If [Target] has a recipe, get missing ingredients first.
3. If [Target] is a base material, use get [Target].
4. If get or craft fails, check recipes and exact item names again.
CORE COMMAND SET:
- craft [target] using [ingredients]
- get [item]
- inventory
INTERACTION EXAMPLE:
[Environment]
Goal: craft powered rail
Recipes:
- craft 6 powered rail using 1 redstone, 1 stick, 6 gold ingot
- craft 1 gold ingot using 9 gold nugget
- craft 1 stick using 2 bamboo
[You]
Think: Recipe for powered rail needs redstone, stick, gold ingot.
I need to check what I have.
Action: [[ inventory ]]
[Environment]
Inventory: [redstone] (1)
[You]
Think: I have redstone. I miss stick and gold ingot. Gold ingot
needs gold nugget, so I should get gold nugget first.
Action: [[ get 54 gold nugget ]]
[Environment]
Got 54 gold nugget.
[You]
Think: Now I have nuggets. I can craft gold ingots.
Action: [[ craft 6 gold ingot using 54 gold nugget ]]
[Environment]
Crafted 6 gold ingot.
[You]
Think: Now I need a stick. Recipe says stick needs bamboo.
Action: [[ get 2 bamboo ]]
[Environment]
Got 2 bamboo.
[You]
Think: I have bamboo. I can craft the stick.
Action: [[ craft 1 stick using 2 bamboo ]]
[Environment]
Crafted 1 stick.
[You]
Think: I have redstone, gold ingots, and stick. I can finally craft
the powered rail.
Action: [[ craft 6 powered rail using 1 redstone, 1 stick, 6 gold ingot ]]
[Environment]
Crafted 6 powered rail.
[You]
Think: Goal achieved.
Action: [[ Task Completed! ]]
Dynamic user observation:
Crafting commands:
{crafting_commands}
Goal: craft {goal_item}.
BabyAI.
You are an exploration master in the BabyAI environment. Every round I
will give you an observation and the currently available actions. Your
goal is to complete the given navigation or object-manipulation task.
Common actions include:
- turn left
- turn right
- move forward
- go to <object> <id>
- pickup <object> <id>
- drop
- toggle
- go through <door> <id>
- toggle and go through <door> <id>
- check available actions
Your response should use exactly this format:
Thought:
your thoughts.
Action:
[[ your next action ]]
IMPORTANT: Output exactly one executable action and always wrap it in [[ ]].
Dynamic user observation:
Your goal: {mission}
{natural_language_grid_observation}
Available actions: [{available_actions}]
ALFWorld.
System prompt:
You are an agent in the ALFWorld environment. Your goal is to complete
household tasks by interacting with objects in various rooms.
You can use actions like:
- go to [location]
- take [object] from [location]
- put [object] in/on [location]
- open [object]
- close [object]
- toggle [object]
- clean [object] with [location]
- heat [object] with [location]
- cool [object] with [location]
- examine [object]
- inventory
Instructions:
- Read the task instruction carefully.
- Plan your actions to complete the task.
- Navigate between rooms as needed.
- Manipulate objects correctly.
Your response should contain only the action.
Fixed user message:
Please help me complete the household task. I will provide you with the task description.
Dynamic environment observation:
{room_observation}
Your task is to: {household_task}
The main paper reports the ablations that directly test trajectory construction, replay, prefix-signal assignment, loss combination, and prefix-side training diagnostics. Here we provide lower-level TextCraft sensitivity studies for prefix clipping.
For completeness, we define the prefix-side signals used in Table 4:
Constant assigns every valid prefix token a unit positive weight.
Positive continuation clips the continuation-derived prefix weight at zero.
Success-gated applies a unit prefix weight only when the continuation rollout succeeds, and sets the prefix weight to zero otherwise.
Family lift groups queries generated from the same teacher trajectory into one raw no-prefix query and several prefix queries; it computes the lift of a prefix query relative to the raw query and combines this non-negative lift with the continuation-magnitude signal.
Continuation-magnitude anchor uses the absolute continuation signal as the prefix weight.
Full-demo query adds the complete teacher trajectory as an additional query in the same group, uses SFT-computed old log-probabilities for its assistant tokens, and assigns it the demo advantage \(\mathrm{clamp}(R_{\mathrm{demo}}-\bar{R}_{\mathrm{raw}},0,1)\).
Table 13 summarizes the completed prefix-clip sweep. The main symmetric range \(0.2/0.2\) gives the strongest Pass@8; tighter, looser, or asymmetric
settings generally reduce multi-sample recovery. The prefix-only \(0.28/0.2\) and asymmetric \(0.5/0.2\) settings remain competitive but do not match the main setting. These results indicate
that prefix updates benefit from clipping, but overly permissive clipping can weaken the old-logprob anchor.
| Prefix clip setting | Avg@1 | Pass@2 | Pass@4 | Pass@8 |
|---|---|---|---|---|
| \(0.1/0.1\) | 78.50 | 84.50 | 87.83 | 89.80 |
| \(0.2/0.2\) (main) | 81.63 | 88.18 | 92.71 | 96.00 |
| \(0.3/0.3\) | 69.00 | 75.11 | 80.61 | 87.88 |
| \(0.5/0.5\) | 74.12 | 81.75 | 85.83 | 89.00 |
| \(0.2/0.1\) | 73.50 | 81.29 | 87.01 | 90.62 |
| \(0.28/0.2\) | 79.75 | 85.61 | 89.74 | 93.00 |
| \(0.5/0.2\) | 79.48 | 84.79 | 88.33 | 90.82 |
6pt
Table 14 reports the BabyAI construction-family ablation together with replay-validation statistics. All four construction families achieve similarly high replay-validation rates, ranging from 97.68 to
98.07, which suggests that replayability is not the main bottleneck in this shorter-horizon environment. However, downstream RL performance still differs across construction rules: Entropy-Change Top-3 obtains the strongest results across all
reported metrics, reaching 100.00 Pass@8. This mirrors the TextCraft finding that construction quality is not determined solely by whether a prefix can be replayed, but also by whether the selected cut states provide useful learning signals
for subsequent RL.
| Construction | Val. Rate | Replay Failures | Avg@1 | Pass@2 | Pass@4 | Pass@8 |
|---|---|---|---|---|---|---|
| Fixed-Ratio 0.1/0.3/0.5 | 97.98 | 196 | 92.50 | 94.92 | 96.17 | 96.67 |
| Fixed-Ratio 0.25/0.5/0.7 | 98.07 | 188 | 92.50 | 94.44 | 95.48 | 96.67 |
| Raw-Entropy Top-3 | 97.68 | 204 | 90.83 | 93.13 | 95.48 | 97.78 |
| Entropy-Change Top-3 | 97.70 | 202 | 94.31 | 96.98 | 98.56 | 100.00 |
2pt
Figure 3 visualizes the TextCraft main-change-top3 training run. The first 20 steps are dominated by long responses and many interaction turns, while the last 20 steps are much shorter
and more successful: mean reward increases from 0.489 to 0.835, mean turns decrease from 26.60 to 11.06, and mean response length decreases from 2863 to 426 tokens. This suggests that Prefix-GRPO changes both task success and interaction style.
The final checkpoint is evaluated on 800 samples covering 100 TextCraft tasks, with no missing samples, no generation or environment errors, and no goal mismatches. Figure 4 (a) shows the
depth-wise breakdown: Prefix-GRPO solves nearly all depth-1 and depth-2 tasks under Pass@8, while the remaining errors concentrate in deeper recipes. Depth 3 has 0.50 Avg@8 and 0.92 Pass@8; depth 4 remains difficult
with 0.042 Avg@8 and 0.333 Pass@8.
Among 800 evaluated samples, 653 succeed and 147 fail. Successful rollouts require 8.02 turns on average, while every failed rollout reaches the 30-turn limit. Figure 4 (b) summarizes final-observation categories for failed trajectories. Most failures are not parser failures: only one failed sample ends with an invalid action. The dominant failures are resource-state errors, including unavailable items (46 cases), insufficient inventory for craft (42 cases), crafted non-terminal items (30 cases), and unfinished item acquisition (26 cases).
Figure 5 shows representative TextCraft rollouts from the trained Prefix-GRPO policy. The successful composter trajectory illustrates concise state tracking: after acquiring the required slabs, the policy immediately executes the terminal craft action. The failed magma block trajectory illustrates a remaining failure mode: the policy makes partial progress but then enters a repeated ingredient-recovery loop and reaches the turn limit.
Corresponding author. (hongke@tju.edu.cn)↩︎