Repository navigation
fix(agents): keep the typed cause of a failed custom agent run - #5740
Conversation
CritPt and SciCode raised the resources server's /verify failure out of /run, so the HTTP boundary dropped the generated answer and the row ended as an untyped agent_run_error. Both now use the verify retry helper GDP.pdf already uses and return the answer as a masked zero typed with the agent route failure, whose causes keep the verifier error. The masking moves into one helper shared by the three agents. Signed-off-by: Adam Rajfer <[email protected]>
A policy request that timed out on every attempt was typed only inside Simple Agent. For any other agent the responses route reported a generic route failure, and Collection saved a failed /run as a bare agent_run_error even when its reply named the cause. The responses route now raises the typed policy-timeout failure from a confirmed timeout, shared with Simple Agent, and Collection types the row with the first non-routing kind on the failure chain of the reply. Signed-off-by: Adam Rajfer <[email protected]>
The vLLM model turns a chat completion into a Response, which carries a stop reason only when generation was cut short. Model-call records of completed calls therefore had no finish reason. The adapter now notes the chat finish reason with the call's execution facts, and the record uses it after the reasons the payload itself reports. Signed-off-by: Adam Rajfer <[email protected]>
Pins that Collection types the row of a failed /run from the resources server's failure chain for an agent that lets raise_for_status escape on /verify, for verifier_error and judge_failed, and for Simple Agent's own verify call. Signed-off-by: Adam Rajfer <[email protected]>
A preparer that fails in its own code or environment (a missing module, say) exited the driver with a traceback and status 1, so the chain queued a follow-up that failed the same way. The failure is now a typed stop, environment_prepare_failed: the CLI exits 76 with an EVAL STOPPED message and records the kind, and the next segment's guard ends the chain with the remedy, as it does for rejected credentials. Signed-off-by: Adam Rajfer <[email protected]>
…onses model The inference provider and the context-compaction vLLM model convert a chat completion into a Response like the vLLM model does, and their model-call records of completed calls also had no finish reason. All three now note it through one helper, so a completed call records stop or tool_calls and a truncated one keeps max_output_tokens. Signed-off-by: Adam Rajfer <[email protected]>
… call The OpenAI-compatible model server answered every provider error it had not been told to forward with a bare 500, so a judge behind it reported "500 Internal Server Error" when the provider had rejected the credential. It now forwards 401, 403 and 429 with the provider's body by default (an empty propagate_upstream_http_status_codes restores the old behaviour), and a failed judge call puts the reply's bounded body in its failure reason. Failure kinds are unchanged. Signed-off-by: Adam Rajfer <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]> # Conflicts: # nemo_gym/orchestration/executors/resume_script.py
GDP.pdf scored every model-side HTTP error that was not an input limit as a terminal zero and skipped verification, and swallowed any other exception the same way, so a server fault, a rate limit or a timeout became the model's result and was never retried. Only the limits the agent recognises (size, context window, image count) stay a scored zero. A confirmed policy response timeout now leaves as the shared typed policy-timeout failure, and any other failed call leaves with its typed model failure, so the agent boundary masks the row and Collection retries it within its budget. Signed-off-by: Adam Rajfer <[email protected]>
yuhezhang-ai
left a comment
There was a problem hiding this comment.
Review findings rechecked against f0834cd6c99ec24ba1b628fd1ca7b22b32728f15 after the PR updates. The original independent passes covered 389deb1c6, with a separate GDP.pdf follow-up through 0ca59b120; the additional changes since then have not received a fresh dual review.
I request changes for the masked-verification recovery gap, parallel-preparation hang, and trajectory-export compatibility regression. The temporary-preparation policy and custom-agent judge-routing comments are narrower, nonblocking follow-ups.
Additional nonblocking improvements:
- Exercise GDP.pdf's production timeout shape: the real
_create_episodealready converts a confirmed timeout intoNgFailureEvent, whereas the new test replaces it with a rawClientResponseError. Restoring the removed broad catch could pass the test while zeroing real timeouts again. Use the already-typed error or run the real helper with HTTP stubbed, and cover one non-HTTP failure. - Update GDP.pdf's README: unexpected errors no longer score zero; with the default
route_failures_to_sidecar=false, a failed/runstops collection. Also update the OpenAI model reference's documented propagation default from[]to{401,403,429}. - Preserve the cause traceback for unexpected in-process preparation errors; the new clean exit can otherwise leave only a message such as
KeyError: 'foo'with no script location.
Validation: focused Python 3.13.14 checks of extracted production code confirmed the worker-handoff failure and the recovery/export selection decisions. The GDP follow-up passed syntax and installed-Ruff checks. Full repository suites and live model rollouts were not run during this review; representative live smoke evidence remains needed for the agent behavior changes.
Review provenance: Codex and Claude Opus 5.5 reviewed independently. Claude's specialist reports were returned, but the original team execution audit remains incomplete after a sandbox startup failure; that session was stopped. The separate foreground GDP follow-up completed execution verification. The comments above reflect Codex's final source/evidence checks, not a claim of a fully verified team run.
| except ConfigError: | ||
| raise | ||
| except Exception as exc: | ||
| raise PreparationFailedError(prepare_module_path, "prepare", f"{type(exc).__name__}: {exc}") from exc |
There was a problem hiding this comment.
[P2, nonblocking policy follow-up] Distinguish temporary preparation failures from permanent defects
This catches a temporary dataset-download TimeoutError/connection failure as well as deterministic preparation bugs; the isolated wrapper similarly treats every nonzero exit, including signal exits, as permanent. On a continuation segment with prepare: configured, saved recovery state and retry budget available, a temporary network failure now records environment_prepare_failed and stops the chain where it could previously spend a bounded infrastructure retry. The first segment could already stop without a rollout manifest, so this concern is specifically about continuation jobs.
Could transport/infrastructure failures retain bounded recovery, or could the new manual-retry policy be made explicit? The statement that another attempt cannot succeed is not established for these cases. A reduced check confirms that a TimeoutError gets the new terminal marker; the scheduler consequence was source-traced, not exercised on Slurm.
There was a problem hiding this comment.
Agreed that a transient download failure should not stop a continuation segment. I'll handle it in a follow-up rather than here, so this PR does not change the retry policy: classify transport failures in preparation as retryable and keep the terminal stop for deterministic script errors.
| event = report.events.get(current) | ||
| if event is None: | ||
| return None | ||
| if event.failure_kind not in _ROUTING_FAILURE_KINDS: |
There was a problem hiding this comment.
[P2, nonblocking custom-agent follow-up] Distinguish judge failures with and without a saved answer
If a custom /run fails with judge_failed as its first non-routing cause, this promotion makes the saved sidecar class judge_failed, although an HTTP request failure has no response. has_unclassified_execution_failure then immediately blocks agent reruns because it assumes judge-only recovery owns the row. That recovery has no answer to grade; binding it can also abort payload preparation for other legitimate judge failures in the same pass.
An exact-function reduced check confirms that the same event chain is not blocked as agent_run_error but is blocked after this promotion. Stock judge_failsafe normally returns a saved-answer HTTP-200 result, so this is a narrower custom-agent contract issue; the new [judge_failed] test nevertheless endorses this failure shape.
Please retain the typed diagnostic while making recovery routing depend on whether an answer was actually saved, and cover both shapes.
There was a problem hiding this comment.
Fair point, a request failure has no answer to grade. I'll keep that out of this PR and fix it in a follow-up by promoting to judge_failed only when the row kept a saved answer, with a test for both shapes.
…orced tool calls exportable A custom agent's /verify reply with a server error or rate limit is typed judge_failed, so recovery grades the saved answer again with /verify only; the CritPt and SciCode verifiers report themselves stateless so that replay is admitted. PreparationFailedError survives pickling across a preparation worker, so a failing parallel preparation exits 76 instead of hanging. ATIF export accepts the stop finish reason of a named or forced tool call on a Responses call and still rejects truncation. Signed-off-by: Adam Rajfer <[email protected]>
|
Thanks for the thorough pass. The three blocking items are fixed in 105110c (masked verify recovery, picklable preparation errors, forced tool call export), each with a regression test, and the two nonblocking ones are answered in their threads as follow-ups. Could you take another look? |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
Focused follow-up at 105110c865c16c1de7750e4bc8dad7a2a6881ca0.
The preparation-worker serialization and forced-tool trajectory-export fixes are verified; I am resolving those two original threads. The saved-answer recovery finding remains open: its new implementation exposes two benchmark-specific problems described in the new inline comments (SciCode loses its generated solutions and can settle as zero; CritPt cannot grade a failed subset without a full batch).
The two earlier nonblocking follow-ups remain deferred, as acknowledged in their replies.
Validation: focused Python 3.13.14 checks used the updated exception and a real two-process Pool, the updated export validation block, the actual regrading request-builder/SciCode verify method, and the actual CritPt verify/batch-wait methods. Helpers and other preconditions were controlled where dependencies were unavailable. This was a Codex follow-up, not a fresh dual review. Full suites, live model runs, sandbox execution, and real AA grading were not run.
…single-row replay A regrade payload now carries the accumulated solutions and usage accounting a masked SciCode row saved, so the verifier grades every sub-step instead of the last one. CritPt grades only full batches, so one saved answer cannot be graded alone: its server no longer declares STATELESS and its agent keeps the agent_route_failed kind for a failed verify call instead of claiming single-row recovery. Signed-off-by: Adam Rajfer <[email protected]>
|
Both new items are addressed in 41ae84e: SciCode regrades now carry the saved solutions, and CritPt is taken out of single-row replay instead of declaring it. Could you take another look? |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
Approved the reviewed code at 41ae84e8491b5995a592686ba00a3e83c1c156d7 after the follow-up fixes.
The worker-serialization and tool-call export regressions are addressed. SciCode recovery now preserves its generated solutions and step accounting. CritPt correctly opts out of unsupported single-row replay; batch/cache recovery remains an explicit limitation.
Latest-head CI shows successful core tests/combined coverage, server suite, sandbox tests, lint and DCO, with no failed or pending checks observed. My own verification used focused checks of the changed production code, including the real worker boundary and the corrected SciCode payload path; I did not independently rerun full suites or live model rollouts. The PR still reports no live rollout, so representative model validation remains an author-side pre-merge requirement.
The temporary-preparation retry policy and custom-agent judge-routing items remain acknowledged nonblocking follow-ups. The PR description should also reflect CritPt's conservative replay scope. This approval does not treat those follow-ups as implemented or attest that the earlier Claude team execution audit completed.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42290328950 |
Behaviour. A rollout that fails inside a custom agent kept no typed cause. When a resources server's verify raised (a grader rate limit, a judge error) and the agent let the HTTP error escape, or when a custom agent's own policy call timed out, the saved row ended as a bare
agent_run_errorwithfailure_kindnull, neither masked nor final, never retried, and the generated answer was lost with the 500. Only SimpleAgent typed these paths. Two more gaps surfaced on the same runs: a benchmark whose data preparation fails deterministically was retried by the job chain, andfinish_reasonwas never recorded for chat-backed Responses calls, so a truncated answer could not be told from a completed one.Change.
/verifyor policy failure escapes still yields a typed row (verifier_error,judge_failed,model_policy_response_timeout, ...), SimpleAgent included.verify_with_transport_retryand return the saved answer as a masked row with the verifier error on the cause chain, so recovery regrades instead of regenerating (sharedmasked_verify_failurehelper, the pattern GDP.pdf used inline).agent.responsesboundary;policy_timeout_failuremoved toagent_outcome.pyand is shared.finish_reasonin the call's execution facts; truncated calls keepmax_output_tokens.propagate_upstream_http_status_codes, default{401, 403, 429}; empty set restores the old behaviour), so judge and policy failure reasons name the real cause.Checked. Unit suites plus simple_agent, critpt, scicode, the model servers and gdp_pdf: 20626 passed, 50 skipped; the 11 failures also fail on the base commit (harbor run-summary, locked-env, benchmark listing, opensandbox help, ci_environment). New tests cover the raw-verify typing for a minimal agent, for a judge failure and for SimpleAgent, the typed policy timeout, the preparation stop, the finish reasons, and the upstream status propagation. ruff clean.
Not covered. No live rollout. Out-of-process harness agents (CLI or sandbox clients) still report policy timeouts as the harness sees them; agents that keep a raw
raise_for_statuson verify get a typed row but still lose the answer, so recovery regenerates for them until they adopt the masked path.Revert. Revert the branch; nothing else depends on it.