rollout: subtract agent-reported tool time from throughput accounting#1663
Merged
Conversation
Shi-Dong
requested review from
fzyzcjy,
guapisolo and
yueming-yuan
as code owners
July 14, 2026 03:49
3 tasks
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds logic to extract total_tool_time from the agent's metadata and assign it to each sample's non_generation_time attribute to account for non-generation time in throughput calculations. The review feedback suggests defensively verifying that agent_metrics is a dictionary before calling .get() and validating that total_tool_time is a non-negative number to prevent runtime errors.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
yueming-yuan
approved these changes
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a small, env-agnostic hook to the generic agentic generate function (
miles/rollout/generate_hub/agentic_tool_call.py) so that wall-clock time an agent spends outside policy generation (environment steps, tool calls, sandbox exec/eval) is surfaced onSample.non_generation_time.Why
agentic_tool_call.generateis the shared generate function used by every agent-environment RL path (Harbor/swe-agent-v2 and OpenEnv alike). The throughput/perf metrics inmiles/ray/rollout/metrics.pyderive per-sample tokens/sec from the total rollout wall-clock. In a multi-turn agentic rollout a large fraction of that wall-clock is env/tool latency, not decoding — so the reported tokens/sec is badly understated and not comparable across envs with different tool latencies. This hook lets the perf accounting subtract non-generation time and report a generation-only throughput.How
If the agent function returns
agent_metrics.total_tool_time, that value is written tonon_generation_timeon every turn-sample of the episode. The value must be identical across turn-samples becausemerge_samplescollapses them with_merge_equal_value, which asserts equality. Agent functions that don't report the metric are unaffected (non_generation_timestays at its0.0default).Notes
This was the only core-miles change previously bundled in #1487 (the OpenEnv tbench2 example). It is peeled out here as a standalone, generic change; #1487 now stacks on top of this branch.