Skill-Guided On-Policy Distillation
Sparse task outcomes leave reflective choices hard to learn; Agent-Reflex adds a training-only skill-conditioned teacher that re-scores sampled actions and softly guides the ordinary policy.
Read the paper ↗What it is
- Mixed clean and noisy rollouts The agent learns from ordinary task outcomes while some interactions include perturbed tool feedback, keeping failures in the same learning group as clean attempts.
- Skill-guided rescoring After the agent acts without a skill prompt, the same policy checks how likely those exact action tokens look when an environment-specific skill card is added.
- Soft token guidance A token gets more learning weight when the skill-conditioned view favors it; the skill prompt guides training, but is not needed when the agent is deployed.
Why it matters
A final success or failure is a blunt signal for a long tool interaction. Rescoring the agent’s own actions gives token-level guidance about reflective choices, while the outcome objective still teaches whether the whole interaction worked.
Before we get into the machinery, the basic idea is simple: let an agent try a tool task normally, then give its own policy a second look at the actions it just took—with a short skill card for that environment. If that skill-informed view favors a particular action, training nudges the ordinary policy toward it. The skill card helps during training, but the deployed agent does not need it.
- Sparse feedback: A verifier can say whether a whole tool interaction worked, but that does not pinpoint which action helped or hurt. The canonical example is a tool call that returns an error: the final score does not tell you whether the agent should retry, change its query, or abandon that route. More generally, a long sequence gets one coarse outcome signal.
- Learning under messy feedback: The agent should encounter perturbed tool interactions, but failures should not become a separate world with their own comparison baseline. Think of one practice group containing mostly normal runs and a few runs where the tool behaves unexpectedly. The reported setup mixes clean and noisy trajectories before normalizing their returns; that keeps the noisy failures in the same on-policy group. The analogy is a mixed practice session, not a claim that every kind of noise is interchangeable.
- Useful reflection without a deployment crutch: A skill card can explain what tends to go wrong in an environment, but requiring it at runtime would make the agent depend on that extra prompt. Here it acts more like a coach reviewing the agent’s own notebook after the action: it helps assess choices during training, while the agent’s actual trajectory was generated without the card. The limit is that a coach’s preference is guidance, not a verified answer.
So how do we turn that coaching view into a learning signal? The policy re-scores the exact action tokens it already sampled, once with ordinary context and once with the environment’s skill card added. If the card makes a token look more likely, that is a vote to strengthen it in the ordinary context. The score difference is detached from learning, so the policy cannot improve the target simply by changing the coaching score; a soft weight means a weak or negative vote counts less rather than being treated as a hard rejection. In short, the skill view is a training-time lens, not a second actor.
Why keep ordinary reinforcement learning in the loop, then? The token guidance only says which sampled choices the skill-conditioned view favors; the verifier still says whether the overall interaction paid off. The method combines those signals: one learns from outcomes across the mixed rollout group, while the other supplies denser pressure on individual action tokens. I like the separation because it makes the skill signal an assistant rather than a replacement for task success. But does the same-policy coach always know better? Not necessarily—the quality and fit of the environment skill still matter, and a favorable score shift is not a correctness guarantee.
Read the deep dive
Why People Wanted It
A tool agent can finish a task successfully or fail, but that final outcome does not say which intermediate action deserved credit. When an interaction contains a bad tool result, the useful lesson may be a reflective choice—checking, changing course, or not repeating an unhelpful action—buried among many tokens. The real question is how to give the current policy denser guidance on those choices without replacing the outcome signal or requiring extra environment rollouts.
The Core Move
Roll out the ordinary policy on a mixture of clean and perturbed interactions, then let that same policy re-score its sampled action tokens with an environment-matched skill prompt; use the skill-induced score shift as detached, confidence-weighted guidance while retaining the ordinary reinforcement-learning objective.
For a sampled action token in ordinary history , let and , where is the environment’s skill card. The teacher shift and soft confidence are
The shift is stop-gradient: it weights token guidance from the skill-conditioned view, while policy gradients update the ordinary-context branch.
Why Noisy Agentic Reinforcement Learning Keeps Failures in the Mix
Here is the part that gets technical: the RL signal is computed over a group that deliberately mixes clean and perturbed environment rollouts, rather than treating noisy failures as a separate contrast set. For task , trajectories receive verifier returns and group-relative advantages
Here and are the return mean and standard deviation over the mixed group. The choice matters: a failed perturbed trajectory remains part of the on-policy distribution and contributes through its outcome, but it is not normalized against a noisy-only subgroup. The RL loss applies a clipped policy-ratio objective to valid agent-generated tokens; tool returns and simulated user messages are masked out. Its job is still trajectory-level outcome learning, not to label a particular reflection token as good.
Why the Skill Branch Scores the Same Tokens
Now the version for readers who want more of the machinery: the skill-conditioned branch does not generate a second trajectory. The policy first samples a trajectory without a skill card. Given the known environment, the corresponding skill is loaded directly, and a deterministic history construction adds it only for rescoring those already sampled action tokens. This is on-policy distillation because the student tokens came from the current behavior policy, not from a separate expert demonstration.
For each valid action token, the ordinary branch supplies and the skill branch supplies . The OPD loss uses the detached difference and soft weight . Minimizing the token-level term raises the ordinary-context score of sampled tokens that the skill-conditioned view favors. Detaching the teacher score prevents the policy from changing the target by manipulating the skill branch; only the ordinary branch receives this guidance gradient. A weak or negative shift is down-weighted, not categorically discarded.
Why ORPO Combines Two Different Scales of Feedback
Here is the deeper objective-level point: outcome learning and reflective distillation answer different questions. The group-relative RL term asks whether a whole interaction did well compared with its peers; OPD asks which sampled action tokens receive a higher score when the environment skill is present. The joint objective is
The sum keeps every trajectory in the outcome term, while the confidence-weighted token term supplies denser, skill-guided pressure on the sampled actions. In the described setup the skill branch is a forward-pass-only teacher: it does not query the environment, and its gradients are detached. What remains open is whether the balance between these two signals stays useful when the skill-conditioned score shift is weak or misleading.
Minimal Causal Code
The loop below isolates the causal idea: sampled tokens come from ordinary rollouts; the skill context only re-scores them; the detached shift weights an update to ordinary-context log-probabilities. It omits the clipped RL term and batching details.
import torch
import torch.nn.functional as F
# Each batch item contains an already sampled action-token sequence.
# ordinary_logp and skilled_logp are aligned per-token scores from the
# current policy, evaluated on ordinary and skill-augmented histories.
ordinary_logp = policy.log_prob(sampled_tokens, ordinary_histories)
skilled_logp = policy.log_prob(sampled_tokens, skilled_histories)
shift = (skilled_logp - ordinary_logp).detach()
confidence = torch.sigmoid(beta_opd * shift)
# valid_agent_tokens excludes tool returns and simulated user messages.
weights = confidence * valid_agent_tokens
opd_loss = -(weights * ordinary_logp).sum() / valid_agent_tokens.sum().clamp_min(1)
# RL loss is computed separately from mixed-group verifier returns.
loss = rl_loss + opd_loss
loss.backward()
optimizer.step()
What You Gain, and What You Lose
You gain token-level guidance tied to the current policy’s own actions, while preserving verifier-based outcome learning and avoiding a second environment rollout for the skill branch. The confidence gate makes the guidance soft: tokens with a larger positive skill-induced shift receive more weight, while weak or negative shifts receive less.
You also accept limits. The teacher is the same policy under a privileged training-time prompt, not an independent expert; its score shift is a guidance signal, not proof that a token is correct. Skill coverage and the usefulness of the matched skill therefore matter. The method adds a skill-conditioned forward pass and requires the skill library during training, even though the skill prompt is removed at deployment. Finally, group-normalized outcomes remain coarse: OPD helps assign token-level pressure, but does not turn every reflection choice into a verified label.
Let the policy act without a skill, then use the skill-conditioned view to softly teach it which of its own sampled tokens deserve more probability.