[BUG][agent_loop] async reward drops meta_info; custom reward can't see validate flag
Summary
On the experimental agent_loop async-reward path, AgentLoopWorker._compute_score builds the reward DataProto without forwarding meta_info. As a result the reward worker (reward_loop.py → reward_manager.run_single) receives a DataProto whose meta_info is empty, so a custom reward manager can never read data.meta_info.get("validate") (or any other per-batch meta_info key) at scoring time.
The classic reward path does not have this problem: the reward manager's __call__(self, data, ...) gets the full batch DataProto, and the trainer stamps test_batch.meta_info["validate"] = True during validation — so classic custom rewards can branch on train vs. val, but agent_loop ones cannot.
System Info / Version
- verl
0.8.0.dev, worktree HEADbcb63864(committed 2026-04-17). - Also reproduces on current public
main(0.9.0.dev), checked 2026-07-22. - Agent Loop is
.. versionadded:: 0.4.2[status: alpha](docs/advance/agent_loop.rst).
Reproduction
actor_rollout_ref.rollout.mode=async(agent_loop) + a customreward_manageron the async reward path (reward.reward_manager=...).- In
run_single, readdata.meta_info.get("validate", False). - Run training with validation enabled.
- The custom reward always sees
validateabsent/False, in both train and validation rollouts. - Swap to the classic (sync) reward path with the same manager reading
data.meta_info["validate"]→ it correctly readsTrueduring_validate.
Expected vs. Actual
- Expected: agent_loop reward functions can distinguish validation from training via
meta_info["validate"], matching the classic path. - Actual:
meta_infois dropped before the reward manager, sovalidate(and everything else inmeta_info) is unavailable.
Root cause (HEAD bcb63864)
-
verl/experimental/agent_loop/agent_loop.py:881-884— the rewardDataProtois constructed with nometa_info=:data = DataProto( batch=batch, non_tensor_batch=non_tensor_batch, ) # <- no meta_info= -
_compute_score(agent_loop.py:858) doesn't takevalidate, but its caller_agent_loop_postprocess(self, output, validate, ...)hasvalidatein scope — it already forwards it to the sibling call_compute_teacher_logprobs(..., validate=validate)(agent_loop.py:749-753). So the value is available at the call site; it just isn't passed down. -
Reward side receives that
DataProto:verl/experimental/reward_loop/reward_loop.py:148-152(compute_score→reward_manager.run_single(data)).meta_infois empty there. (For evidence thatmeta_infois consulted on this path, seereward_manager/limited.py:495readingdata.meta_info.get("reward_extra_keys").) -
Contrast — classic path:
verl/workers/reward_manager/naive.py:46__call__(self, data, ...)gets the full batch, andverl/trainer/ppo/ray_trainer.py:579setstest_batch.meta_info["validate"] = True(publicmain:ray_trainer.py:663).
Proposed fix
Thread validate into _compute_score and attach it (or the whole meta_info) to the reward DataProto:
data = DataProto(
batch=batch,
non_tensor_batch=non_tensor_batch,
meta_info={"validate": validate},
)
Since validate is already in scope at the caller (and already forwarded to _compute_teacher_logprobs), this is a minimal change.
Questions for maintainers: Is dropping meta_info on the async reward path intended? Is there a recommended way for agent_loop custom rewards to detect validation today? Happy to send a PR if this direction looks right.
Thanks for the detailed report. I have a narrowly scoped patch prepared and tested locally:
- pass the existing
validateflag through both the standard and TransferQueue agent-loop postprocess paths to_compute_score; - set
DataProto.meta_info[validate]before remote async reward computation; - add a CPU-only fake remote reward-handle regression test covering both training and validation values.
Validation completed:
25 passedfortests/experimental/agent_loop/*_on_cpu.py1 passedfortests/trainer/ppo/v1/test_agent_loop_tq_on_cpu.py- Ruff, ruff-format, mypy, compileall, and
git diff --checkall pass
I also confirmed that there is currently no open PR referencing #7121. @CleanDev-Fix, I see that you outlined essentially the same approach; please let me know if you already have a PR in progress so we can avoid duplicate work.
This work was AI-assisted and will only be submitted after the human submitter reviews every changed line and personally verifies/understands the relevant tests, as required by the repository contribution policy.