Repository navigation
Description
Queue rank 16/48 · Difficulty 2/5 · Status on main: not_fixed
NVBug: https://nvbugspro.nvidia.com/bug/6900411 · priority: Unprioritized · ARB: Ananth Subramaniam
GitHub: none found (no fix PR; #55 is the original integration, #3580 is the critpt usage fix)
Summary
AviaryAgent.responses() runs a multi-step loop (model call, /step, model call, ...) but builds the returned response from the last model_response only. usage is never accumulated, so response.usage reports only the final model call's tokens. Every earlier call's input/output tokens are dropped, under-counting any Aviary episode with more than one step. Single-step episodes are correct. toolsandbox_agent has the identical construction (source-only; not re-verified at runtime).
Reproduction
Model-free script in the bug drives responses() with a mocked ServerClient, two turns (300,1400)+(1818,24): reports 1818/24/1842 instead of expected 2118/1424/3542; exit 1. Live: collect multi-step aviary_gsm8k/aviary_hotpotqa rollouts and compare response.usage against POST counts in vLLM logs.
Root cause
responses_api_agents/aviary_agent/app.py: no usage accumulator. :154 model_response = None; :187 overwrites it each step; :249-254 output_overrides omits usage; :255 AviaryNeMoGymResponse.model_validate(model_response.model_dump() | output_overrides) carries the last call's usage. Siblings sum via nemo_gym.openai_utils.accumulate_response_usage (now at openai_utils.py:1133): simple_agent and gymnasium_agent sum normally, while critpt_agent (#3580) uses a null-if-any-missing policy. Aviary was never converted.
Status on main (not_fixed)
HEAD 75bb53e. grep -n usage responses_api_agents/aviary_agent/app.py -> no hits. git diff efe58abe..HEAD -- aviary_agent/app.py empty (byte-identical to rc1; #3728 was an unrelated Ray chore). :249-254 still has no usage key. Recent usage fixes #3580 (critpt), #4139 (hermes), #4287 (health) touch other agents. reward_profile.py:165-166,433 copies the under-counted response.usage into rollout fields and aggregates.
Proposed fix
Apply the bug's validated diff to aviary_agent/app.py: import accumulate_response_usage; init usage = None; after :189 validation call usage = accumulate_response_usage(usage, model_response.usage); add "usage": usage.model_dump() if usage else None to output_overrides. Add a tests/test_app.py case with two mocked usage-bearing responses asserting summed values. Document the partial-usage (skip-None vs null) policy in README. Apply the same fix to toolsandbox_agent/app.py:211 (or track separately). Expect rebase against open PRs #3109/#3792/#3805.
Validation
QA: testcases/environments/aviary_gsm8k.py, aviary_hotpotqa.py, testcases/integrations/model_call_capture_agent_backends.py. The capture test already sums per-call tokens_in/out; add an assertion that response.usage equals that per-call sum. Re-run all three after the fix.
Triage
Difficulty 2/5 — localized one-file fix, root cause pinpointed, diff applies clean, unit-testable without GPU. Needs GPU: no.
Reviewer notes
Verifier confirmed all paths and status not_fixed on main (HEAD 75bb53e); difficulty held at 2. Corrections applied: accumulate_response_usage now lives at openai_utils.py:1133 (the slim record's 943-966 was stale); and the sibling grouping is reconciled — simple/gymnasium sum normally while critpt (#3580) uses null-if-any-missing, so it is not grouped identically. toolsandbox parallel flagged as source-only.
Activity