Skip to content

[NVBug 6978294] Report null usage when a finished call's usage is lost, and zero when no call finished #4940

Closed

Description

@qiaochuz-nv

Difficulty 2/5 · Status on main: not_fixed · Blocked by: #4761 (open)

NVBug: https://nvbugspro.nvidia.com/bug/6978294 · Related: NVBug 6900411 (#4504), #4716, #4753, #4761

Summary

Agents that sum per-call token usage break two of the three cases in Gym's documented contract
(rollout-evidence.mdx L163-167, rollout-health.mdx L145-150, from #4287):

  • When a finished response's usage is missing or malformed, the usage must be null. Instead, the agents sum the
    other calls (accumulate_response_usage skips a None), so a subtotal reads as the rollout's total.
  • When no call finished, the usage must be zero. Instead, conversational_tool_use_scenario_generation reports
    null when every request fails.

Reproduction

Model-free script, run on a git archive of main 9334fa27c:

  • aviary: 2 finished calls, the second without usage → usage = 300/1400/1700 (expected null).
  • scenario generation: 3 requests, all rejected → usage = null (expected zero).

Affected (main 9334fa2)

Proposed fix

A shared helper in nemo_gym/openai_utils.py that returns the sum, zero, or null with a completeness flag, as
scicode_agent's usage_complete does. Switch every summing agent to it. Tests per agent: a known and a lost-usage
finished call in both orders → null; no finished call → zero where the agent sees every call. This is the
follow-up yaoyu-33 asked for on #4761.

Triage

Waiting for #4761 to merge so that one PR covers every agent off main. No GPU needed for unit tests; a capture
smoke on h100 for the live check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions