Skip to content

fix(swe_agents): mask verified runtime startup failures - #4034

Open
linj-glitch wants to merge 8 commits into
NVIDIA-NeMo:mainfrom
linj-glitch:linj/swe-agents-mask-runtime-died
Open

linj-glitch wants to merge 8 commits into
NVIDIA-NeMo:mainfrom
linj-glitch:linj/swe-agents-mask-runtime-died

Conversation

@linj-glitch

@linj-glitch linj-glitch commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Mask only verified OpenHands runtime startup failures. Server process died alone cannot distinguish infrastructure faults from agent commands that kill or exhaust the runtime.

For the pinned OpenHands revision 54d2a95edc666551b854a7e5d4205ec69e60ff23, a host-owned observer tracks the controller and every runtime process by run nonce, peer PID, and process start time. Controller/runtime audit hooks acknowledge executable setup before it runs; policy actions are acknowledged before dispatch. Once execution starts, retries cannot reset that state. Eligibility crosses Ray as trusted return metadata; agent-writable metrics cannot forge it.

A normal Python startup/import failure before any executable setup or action can receive runtime_death_cause: pre_execution and be masked. Missing or disconnected observation, stale identities, unobserved retries, refused instrumentation, SIGKILL/segfault, other OpenHands revisions, and every post-execution death remain unknown and scored unless an independent mask applies. Broader post-action attribution would require trusted OS/provider termination evidence that this runtime does not expose. The deadline guard and existing timeout/OOM/evaluator masks remain unchanged. There is no broad runtime-death masking option.

No separate issue is needed: this addresses the review's concern that automatic masking could discard negative policy feedback. Compared with unconditional runtime masking, more ambiguous episodes remain in training; benchmark rewards are unchanged.

Validation

Head 65b550c94b266035f85ecd54897be8e6611be153 additively merges main 166af7d0d2aeeb2c645019b88c9210f25405199e to include the upstream colored R2E assertion repair. All six PR-specific files are byte-identical to 1ac9354a583c0a0cde33c02afd86a7527ee97e8e; the remaining merge changes match main. Python 3.13.14 imports were asserted to resolve to this checkout for Gym, SWE, and AnySWE.

  • PY_COLORS=1 python -m pytest -q -o addopts= --import-mode=importlib responses_api_agents/swe_agents/tests responses_api_agents/anyswe_agent/tests: 325 passed, including the colored R2E regression. The runner disables editable-package redirects before asserting source paths.
  • detect-secrets==1.5.0 over all six changed files: passed; the prior finding was the public OpenHands revision constant, now annotated on that line only, with no scanner configuration or baseline change. The Python AST is unchanged.
  • Real subprocess regressions cover clean startup failure, controller/runtime setup, self-kill, signals, absent/stale identities, refused audit-hook installation, and retries after actions or without instrumentation.
  • Failed-command regression proves forged mounted metrics cannot create eligibility. Capture-overlay composition remains intact when the observer connection fails.
  • The real Poetry launcher exposed an entrypoint-matching bug; exact Python-entrypoint matching now has both forwarding-argument and real launcher/process-chain regressions.
  • Independent checks reproduced the process matrix, forged-metrics rejection, and failed-observer capture composition.
  • Full pre-commit run --all-files, complete PR-diff/body guardword scans, and PR-diff whitespace checks against main: passed. An inherited main fixture has a trailing blank line when comparing the merge against the old branch; it is unchanged from main and outside this PR diff.

Rollouts

The earlier bounded real Apptainer/OpenHands/Qwen3-1.7B smoke, using the runtime-entrypoint fix published as e635a6d7e291d42b5f9fa58ef8e6553e97369504, on psf__requests-1766 authenticated both controller and runtime, observed both coverage-ready events and executable setup, and completed one genuine model call. It retained runtime_death_cause: unknown; the existing one-turn limit caused the normal max_iteration mask. No patch was produced, so this is lifecycle/model wiring evidence, not patch-grading evidence. The separate lifecycle regressions execute real local Python processes and include the positive pre-execution-failure case. The live smoke was not repeated for this main merge; the six PR-specific files are unchanged from the prior head.

Checklist

  • Read the contributing guidelines; changes remain focused.
  • Tests and documentation updated.
  • Full pre-commit checks pass.
  • New files have Apache-2.0 SPDX headers.
  • All commits include DCO sign-off.

Required current-head CI and maintainer approval remain merge gates.

@copy-pr-bot

copy-pr-bot Bot commented Oct 5, 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.

@yaoyu-33 yaoyu-33 added area:agent Agent harnesses and Responses API agent behavior bug Something isn't working complexity:low Localized change in one scope with a small, straightforward review surface needs-review PR is ready for code review and waiting on a reviewer labels Oct 5, 2026
@linj-glitch
linj-glitch marked this pull request as draft October 5, 2026 06:11
@linj-glitch
linj-glitch force-pushed the linj/swe-agents-mask-runtime-died branch from c5e79f9 to dd530f8 Compare October 8, 2026 00:15
When the OpenHands action-execution server (the process that runs the
agent's commands inside the container) exits under the agent, OpenHands'
local runtime raises "Server process died" and the episode ends with an
error such as "AgentRuntimeDisconnectedError: Server process died".
_classify_agent_error bucketed that as "other", so the rollout was scored
as a genuine task failure (reward 0, not masked) although the policy did
nothing wrong. It is an infrastructure failure like the OOM kills and
timeouts that are already masked. In one internal GRPO run it hit 5 of 256
rollouts in a single step and none in the neighbouring steps, i.e. bursts
of spurious zero rewards.

Classify it as "runtime_died" and add it to the mask_sample condition.

Signed-off-by: Lin Jia <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@linj-glitch
linj-glitch force-pushed the linj/swe-agents-mask-runtime-died branch from dd530f8 to cff8bc5 Compare October 8, 2026 00:20
@linj-glitch
linj-glitch marked this pull request as ready for review October 8, 2026 00:31
@linj-glitch

Copy link
Copy Markdown
Collaborator Author

/ok to test cff8bc5

@wdykas

wdykas commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

does your cover #4002 ? or we still need separate?

@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Oct 9, 2026

@alexandery-nvidia alexandery-nvidia 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.

Approving from the training-consumer side; this is the one Lin flagged for Ananth's eligibility call.

Masking an infrastructure death instead of scoring it matches how the trainer treats infra failures, and I traced the flow at the head: the flag lands on the top-level mask_sample of the verify response (the BaseVerifyResponse contract field) with the instance_config copy kept for one release, which is exactly the pair NeMo RL's collector reads. Ran responses_api_agents/swe_agents/tests/test_app.py at the PR head locally: 188 passed, 0 failed, including the three new tests. Two notes: the branch now conflicts with main in app.py and tests/test_app.py (merged #4002 extended the same masking condition), so it needs a rebase that merges the two condition lists; and one training-side consideration inline.

Comment thread responses_api_agents/swe_agents/app.py Resolved
@giuliolovisotto

Copy link
Copy Markdown
Contributor

Thanks, masking genuine runtime crashes makes sense. One concern: the agent runs under timeout --signal=TERM, which signals the whole process group. When the time limit fires, the action-execution server can die first, and OpenHands may then write "Server process died" to output.jsonl. That rollout would be masked as runtime_died, even though a run hitting its own time limit is a real result that should stay in the score. Could you exclude that case, e.g. classify runtime_died only when openhands_run_time < swebench_agent_timeout, and add a test for a runtime death caused by the timeout? Separately, swe_agents already masks agent_timed_out rollouts on main; we'd like those to stay in the score too and are tracking that as a follow-up.

- @claude

@linj-glitch

Copy link
Copy Markdown
Collaborator Author

Addressed the timeout-classification concern in 7d41829: a runtime-death error at or after swebench_agent_timeout now stays other, while an earlier death remains runtime_died. The new processing-level regression exercises metrics and masking before, at, and after the budget; the two deadline cases failed before the guard. All 228 swe_agents tests and full pre-commit passed. The existing explicit agent_timed_out policy remains for the separate follow-up.

On the #4002 question: that PR is now merged, and this head retains its evaluator-launch-failure mask condition and regression coverage. Runtime death and evaluator launch failure remain distinct cases.

The separate concern about an agent causing its own runtime death is still an eligibility-policy question; the timing guard does not establish causality. That thread remains open for Ananth’s review. No fresh live-model rollout was run for this update.

@linj-glitch linj-glitch changed the title fix(swe_agents): mask rollouts whose OpenHands runtime server died feat(swe_agents): add opt-in runtime-death masking Oct 24, 2026
@linj-glitch linj-glitch changed the title feat(swe_agents): add opt-in runtime-death masking fix(swe_agents): mask verified runtime startup failures Oct 24, 2026
@linj-glitch

Copy link
Copy Markdown
Collaborator Author

/ok to test e8e96b7

@linj-glitch

Copy link
Copy Markdown
Collaborator Author

/ok to test e635a6d

@linj-glitch

Copy link
Copy Markdown
Collaborator Author

/ok to test 1ac9354

@linj-glitch

Copy link
Copy Markdown
Collaborator Author

/ok to test 65b550c

@giuliolovisotto giuliolovisotto 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.

Re-reviewed the runtime-startup masking path. My earlier timeout-classification concern is addressed: reaching the agent budget does not establish a spontaneous runtime failure. The new mask requires host-observed pre-execution evidence; absent, disconnected, stale or post-execution evidence remains unknown.

Validation at 65b550c94b266035f85ecd54897be8e6611be153: 15 Linux observer subprocess tests passed, covering setup, signals, missing/stale observation, retries and capture-overlay preservation. Application tests: 216 passed; two process-kill tests could not run successfully on macOS because they require /proc. The changed timeout/masking and forged-metrics tests passed.

No new live Apptainer/model rollout or full CI run. Existing timeout/OOM masking policy is unchanged and remains separate follow-up work.

— @codex

This branch was previously deployed

1 inactive deployment
public — 65b550c9 Deployed Oct 29, 2026 by copy-pr-bot[bot] via release / finalize / notify #8027
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 complexity:low Localized change in one scope with a small, straightforward review surface needs-review PR is ready for code review and waiting on a reviewer sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants