Skip to content

fix(swe_agents): name the failure_kind of masked samples - #5342

Merged
oyilmaz-nvidia merged 4 commits into
mainfrom
yuhez/4882-swe-agents-failure-kinds
Nov 5, 2026
Merged

oyilmaz-nvidia merged 4 commits into
mainfrom
yuhez/4882-swe-agents-failure-kinds

Conversation

@yuhezhang-ai

@yuhezhang-ai yuhezhang-ai commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Third slice of #4882 (parent #3180), after #5223 and #5315. swe_agents masks a sample for six conditions but leaves failure_kind empty, so a consumer can't tell the agent's own limits from infrastructure failures. NVIDIA-NeMo/RL#4968 adds an opt-in GRPO mode that keeps a masked sample in the advantage calculation only if its failure_kind is a policy failure. Without a kind, every swe_agents mask is treated as infrastructure. This PR names the kind and reason for each condition. The mask decision and rewards stay as they are.

Masked condition failure_kind
The evaluator failed before its startup marker, so no reward was measured provider_unavailable
The memory watchdog killed the agent container provider_oom_killed
The memory watchdog killed the eval container provider_oom_killed
The eval hit swebench_tests_timeout swe_agents:eval_timeout
The agent hit swebench_agent_timeout agent_timeout
The agent ended in a max_iteration error agent_limit
The agent ended in a context_window error model_context_limit
  • One function decides both. The mask condition moves into _masked_failure, which returns the kind and reason of the first match, in the table's order.
  • An unmeasured reward comes first. Failures that leave the reward unmeasured are checked before the agent's own limits, so a run that hit its iteration limit and then lost its eval container isn't reported as a measured policy failure.
  • Eval timeouts get their own name. The model's patch can make the tests hang, and so can a slow host, so neither shared group fits. Under RL#4968's default it's left out of advantages. It can be added to the policy list later if that's agreed in tracking: audit reward-zero and fake-success failure producers #4883.
  • How the kind reaches the result. SWEBenchWrapperInstanceConfig carries failure_kind and failure_reason next to mask_sample, and run() copies them onto the verify response.

Overlap with open PRs: #4034 (adds a mask for a runtime that dies before execution) and #4036 (opt-in unfinished_episodes="fail") edit the same mask block. Whichever lands second should put its condition in _masked_failure. #4034's runtime death would map to provider_unavailable.

Validation

Against the final diff on Linux with Python 3.13.14, using the worktree environment with dev, ray, tomlkit, and gprof2dot installed:

TMPDIR=/tmp .venv/bin/gym env test +entrypoint=responses_api_agents/swe_agents +should_validate_data=true +skip_venv_if_present=true
.venv/bin/pre-commit run --all-files
  • All 230 swe_agents tests passed. The component test command reused the prepared worktree environment.
  • The parametrized classification test covers every condition, priority between failures, and two unmasked agent errors (stuck_in_loop, other). The evaluation OOM/timeout cases now overlap with iteration/context limits, which can occur when the agent produces a patch and its evaluation then fails.
  • An in-memory mutation moving iteration/context checks ahead of evaluation OOM/timeout is rejected by both revised cases. The correct implementation passes all nine classification cases.
  • The evaluator-launch test checks that the process_single_datapoint → run() path returns provider_unavailable and a reason for a launch failure, and no kind for a completed eval.
  • Repository-wide pre-commit passed. The private guardword check skipped because its private catalog was unavailable.

Rollouts

N/A. The mask decision is the same set of conditions as before, and rewards are unchanged; only diagnostic fields on masked results are added. The launch-failure test drives the real process_single_datapoint → run() path.

Compatibility and benchmark impact

None for scores. Masked swe_agents rows now carry a failure_kind and failure_reason, and instance_config has the two new fields. With NeMo RL's default (include), training doesn't change. With RL#4968's opt-in exclude_infra, rows with agent_timeout, agent_limit or model_context_limit now count in advantages, and the other masked rows stay out. Their reward is the test result, so an agent_limit row whose patch resolved the tests counts as 1.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated edits are excluded.
  • Tests added or updated and pass locally (230 passed on Linux).
  • Documentation updated: the GRPO masking section of the swe_agents README lists each condition with its kind and the order.
  • Repository-wide pre-commit checks pass locally (private guardword catalog unavailable).
  • New source files include the required Apache-2.0 SPDX header — N/A, no new source files.
  • All commits have DCO sign-off.

@yuhezhang-ai yuhezhang-ai added bug Something isn't working area:agent Agent harnesses and Responses API agent behavior labels Oct 30, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@yuhezhang-ai

Copy link
Copy Markdown
Contributor Author

/ok to test e25bccf

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

@yuhezhang-ai

Copy link
Copy Markdown
Contributor Author

/ok to test 5c760fd

@yuhezhang-ai

Copy link
Copy Markdown
Contributor Author

/ok to test deb0266

@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

LGTM — no concerns found. I reviewed all four changed files and traced the metric producers, failure-kind definitions, public exports, and response serialization. The mask conditions and reward calculation remain unchanged, and the new diagnostics reach the verify response. The tests cover classification precedence and diagnostic propagation.

Static review only; I couldn't execute tests or independently verify the reported validation results.

Note: formal approval is not available for this request, so this review is posted as a comment only.

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

yuhezhang-ai and others added 2 commits November 4, 2026 06:46
swe_agents masks a sample for six conditions but left failure_kind empty,
so a consumer could not tell an agent limit from an infrastructure
failure. The mask decision now goes through _masked_failure, which
returns the kind and reason of the first matching condition; failures
that leave the reward unmeasured come first. The mask itself is
unchanged.

Part of #4882.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>
@yuhezhang-ai
yuhezhang-ai force-pushed the yuhez/4882-swe-agents-failure-kinds branch from deb0266 to 7c75160 Compare November 4, 2026 15:19
@yuhezhang-ai

Copy link
Copy Markdown
Contributor Author

/ok to test 7c75160

@oyilmaz-nvidia

Copy link
Copy Markdown
Contributor

/ok to test 70b1ce3

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42073150613

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 5, 2026
@oyilmaz-nvidia

Copy link
Copy Markdown
Contributor

/ok to test 78510e7

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42078176145

Merged via the queue into main with commit 95ca24f Nov 5, 2026
68 checks passed
@oyilmaz-nvidia
oyilmaz-nvidia deleted the yuhez/4882-swe-agents-failure-kinds branch November 5, 2026 18:02

This branch was previously deployed

1 inactive deployment
public — 78510e72 Deployed Nov 5, 2026 by copy-pr-bot[bot] via release / finalize / notify #10392
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent harnesses and Responses API agent behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants