Skip to content

fix(agent_arena): treat a time-capped turn as an environment-side failure - #5872

Closed
AdamRajfer wants to merge 2 commits into
NVIDIA-NeMo:mainfrom
AdamRajfer:fix/agentarena-time-cap-as-error
Closed

AdamRajfer wants to merge 2 commits into
NVIDIA-NeMo:mainfrom
AdamRajfer:fix/agentarena-time-cap-as-error

Conversation

@AdamRajfer

Copy link
Copy Markdown
Contributor

A turn that hit the agent's wall-clock cap was masked by the resources server under the namespaced kind agentic_turn_simulation:time_cap, with the partial response kept. Recovery keeps a masked row that holds a saved answer and treats a namespaced kind as unclassified, so nothing retried it: the row stayed silently masked. The cap tracks how fast the policy, simulator and judge are served, not what the policy did.

The agent's /run now returns a time-capped turn as a typed agent_time_cap failure (new registered kind, evaluation-side), the way it already returns confirmed model-timeout rows. The collector retries it within the attempt budget, and once that is spent it stays an unscored failed row. outcome_policy selects the action by kind: retry by default, fail to leave it final and unscored, count_as_zero to score it 0. A turn that ends on any other stop reason is verified as before, and the resources server still masks time_cap for callers that do not go through the agent's /run.

Compatibility: through /run a time-capped turn no longer comes back as a masked row with reward: 0.0; it is a failure row with no reward. A training consumer that expects a reward on every /run reply would see a failure instead.

Validation:

  • agentic_turn_simulation_agent, agentic_turn_simulation and agent_arena unit tests, plus the failure-kind, outcome-policy, moved-paths and recovery tests they touch: 1332 passed.
  • New tests read the agent's row through the real Store and recovery decision: one time-capped attempt is retryable, three are exhausted, fail makes it terminal, and the old masked row was final.
  • ruff check and ruff format clean.

Rollout evidence: N/A, no model smoke run; the change is the row the agent returns at the cap and how recovery reads it.

…lure

A turn that hit the agent's wall-clock cap was masked by the resources
server under the namespaced kind agentic_turn_simulation:time_cap, with
the partial response kept. Recovery keeps a masked row that holds a saved
answer, and treats a namespaced kind as unclassified, so nothing retried
it and the row stayed silently masked. The cap tracks how fast the policy,
simulator and judge were served, not what the policy did.

The agent's /run now returns a time-capped turn as a typed agent_time_cap
failure (a new registered kind, evaluation-side), like its confirmed
model-timeout rows. The collector retries it within the attempt budget,
and once that is spent it stays an unscored failed row. outcome_policy
selects the action by kind (default retry; fail or count_as_zero).

Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer AdamRajfer self-assigned this Nov 9, 2026
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 9, 2026 19:02
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test 00cfd64

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHIP WITH CARE

Two correctness risks remain: recovery rejects the advertised count_as_zero outcome, and the override discards completed reference-turn grades. Required real-model smoke evidence is also missing.

NOTE — Update the remaining guidance for time-cap failures

The training guide still describes time caps as masked rows that trainers can filter with mask_sample or rescore using stop_reason. The evaluation reporting instructions likewise count only masked results in the main output. After this change, capped /run replies have neither field nor a saved response, and collection saves them in the failure sidecar. Those instructions no longer account for capped turns.

Suggested correction: Replace the training guide's time-cap filtering advice with:

Through the shipped agent's /run, a time-capped turn is an agent_time_cap failure without a reward or saved response. Handle it before reward or advantage computation; mask_sample does not select these failures. Configure outcome_policy.by_failure_kind.agent_time_cap to choose retry, final unscored failure, or explicit zero scoring. masked_stop_reasons still controls resources-server /verify results, but does not override this /run conversion.

Update the reporting instructions to count selected time-cap failures separately from masked results. Read the Store's latest selected failures rather than concatenating attempts; otherwise a cap followed by a successful retry is counted twice.

Preservation and proposed acceptance checks: Keep masking guidance for simulator failures, first-step context overflow, and direct /verify calls. A saved run with one exhausted cap must report one selected agent_time_cap failure even though its main output has no masked cap row. A cap superseded by a successful retry must not remain in that selected-failure count. Direct /verify time-cap masking and configurable max_steps masking must remain documented, matching the existing assertions.

I inspected all seven changed files and their directly affected paths. Two delegated inspections were cancelled; I completed those topics directly. This was a static, read-only review: I didn't execute tests or rollouts, and suggested patches need verification before adoption.


Inline comments (escaped v1):

  • nemo_gym/orchestration/recovery.py line 1295: RISK — Admit the advertised time-cap zero in recovery.

    With outcome_policy.by_failure_kind.agent_time_cap: count_as_zero, the new producer emits a terminal counted-zero failure whose selected event is agent_time_cap at agent.agent_time_cap. Collection counts that row as zero and the Store settles it, but this recovery branch accepts only four model kinds and rejects agent operations other than agent.policy_request. Consequently, the capped identity becomes unknown, decision.complete stays false, and recovery stops despite the explicitly settled zero. This affects the newly documented policy option, not default retry.

    Correction: Add narrow support for this producer's counted zero without accepting arbitrary infrastructure zeros. For example, import AGENT_TIME_CAP and replace the state assignment here with:

    cap_zero = (
        model_cause == AGENT_TIME_CAP
        and chain is not None
        and len(chain) == 1
        and chain[0][:2] == (FailureBoundary.AGENT, "agent.agent_time_cap")
    )
    state = (
        IdentityState.MODEL_FINAL
        if is_terminal_failure(last)
        and ((model_kind and not contradictory) or cap_zero)
        else IdentityState.UNKNOWN
    )

    Here MODEL_FINAL is the existing settled-sidecar state; the cap's responsibility must remain evaluation-side through the shared classifier. This suggested patch is source reasoning, not an executed result.

    Preservation and proposed acceptance checks: Extend TestTimeCapRecovery with a real _saved_row(...count_as_zero...), persist it using the existing Store helper, and run _decide: expect {"scored": 1, "model_final": 1}, complete=True, and no pending retry. Through collection, one healthy reward and one capped zero must aggregate as [0.0, 1.0], while the failure sidecar still has no reward. Retain default retry/exhaustion and terminal fail. Keep confirmed policy-timeout zeros accepted, and keep nonterminal, missing/cyclic-report, wrong-boundary, and unrelated infrastructure-zero rows rejected. Verify that fault reporting still classifies the cap as evaluation-side.

  • responses_api_agents/agentic_turn_simulation_agent/app.py line 319: RISK — Preserve grades when score_source is reference_turn.

    Run this pairing with score_source: reference_turn, a complete recorded reference, and a policy turn that reaches time_cap. The resources server deliberately ignores policy stop reasons in reference mode, so super().run() returns the recorded turn's completed grade. This unconditional conversion then discards that grade and returns a retryable failure because the unrelated policy hit its cap. Baseline scoring can repeatedly judge the same reference and eventually leave it unscored, although the reference itself was fully gradable.

    Correction: Exempt verified reference-turn results from the policy time-cap conversion. The verifier already returns score_source, and SimpleAgentVerifyResponse preserves extra fields. Replace this guard with:

            if metadata.get("stop_reason") != "time_cap" or getattr(result, "score_source", None) == "reference_turn":
                return result
    

    The invariant is that the cap invalidates a policy turn, not an independently recorded reference turn.

    Preservation and proposed acceptance checks: Add reference-mode cases whose policy metadata says time_cap: a passing reference must retain reward 1.0, a failing reference must retain 0.0, and a reference ending immediately after a tool result must retain its recording_cut_off mask. Keep the existing reference-mode assertion that the policy's max_steps does not affect its grade. In policy mode, the same capped response must still become agent_time_cap; non-capped results and already-returned failure responses must remain unchanged. These checks and the suggested guard haven't been executed in this review.

  • responses_api_agents/agentic_turn_simulation_agent/app.py line 315: RISK — Record the required representative model smoke rollout.

    The PR explicitly reports no model smoke run, but this override changes a capped /run from a masked result with a response into a failure without a reward or response. Protected AGENTS.md requires representative real smoke rollouts for behavior-changing agent work. The new test helper supplies both the episode metadata and verification reply; it doesn't exercise the actual policy → episode → verifier path. The stated unit-test results don't satisfy that separate evidence requirement.

    Correction: Run the paired agent/resources server with a real model on a representative tool-using row, using a reduced cap that expires after some work. Record the command/config, model identities, rollout artifacts, and inspected agent/verifier behavior in the PR. This reusable environment doesn't require a fixed-benchmark reward-distribution comparison for this change.

    Preservation and acceptance: Confirm that the capped /run produces failure_kind: agent_time_cap without reward, mask_sample, or response, closes its resources session, and leaves a retryable saved attempt under the default policy. Run a neighboring non-capped turn and confirm that its verified response and reward remain intact. Retain the deterministic assertions for exhaustion and terminal fail. These are requested checks, not results I executed; no implementation patch follows solely from this evidence gap.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@AdamRajfer
AdamRajfer marked this pull request as draft November 10, 2026 10:47
@copy-pr-bot

copy-pr-bot Bot commented Nov 10, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test 59c1090

@AdamRajfer

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate of #6072 with #6070. There, the turn simulation environment declares retry for a time-capped turn and recovery honors it: a cap hit is retried within the attempt budget, and once the budget is spent the run stays incomplete instead of counting the row. The benchmark owner confirmed that cap hits come from serving capacity. A reply cut off by the output limit already ends the turn as max_output_tokens and scores 0 as an unfinished turn, so no separate agent-side kind is needed.

@AdamRajfer AdamRajfer closed this Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants