Skip to content

feat(agent): add the shared outcome ladder for harness runs - #5870

Open
yaoyu-33 wants to merge 7 commits into
mainfrom
feat/agent-outcome-ladder
Open

yaoyu-33 wants to merge 7 commits into
mainfrom
feat/agent-outcome-ladder

Conversation

@yaoyu-33

@yaoyu-33 yaoyu-33 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Harnesses currently assign different scoring and retry behavior to the same context overflow, rejected request, or missing result. This adds one outcome ladder: adapters supply RunEvidence, decide_outcome chooses the response, and finish_response applies it. Adapter migrations follow in #5875, #5877, #5879, #5880, #5907 and #5873. No separate public issue is needed: this is the shared first step of that cross-harness consistency effort.

Evidence, first matching row Response Default disposition
Rollout stop or cancelled close incomplete; rollout stops carry ng_rollout_stop Verify
Explicit context overflow incomplete Verify
Deadline with an unrecovered or in-flight infrastructure fault failed, classified fault By the fault kind's policy; retry for transient server/provider faults
Deadline incomplete Verify; the temporary retry_deadline_before_reply flag preserves existing retries until model-call session correlation is complete
Terminal error failed, classified error; a nonretryable 4xx before any reply becomes model_request_rejected By outcome policy
Output limit, or turn limit without a final answer incomplete Verify
Refusal or usable result completed Verify
Otherwise, no usable result failed, agent_run_error Retry

A final answer at the harness step limit uses has_result plus HARNESS_STEP_LIMIT_METADATA_KEY. Recovered faults do not qualify as deadline infrastructure evidence. The HTTP classifier shares the model client's context-overflow parser, including wrapped error envelopes, and safely handles unexpected statuses and deeply nested bodies.

finish_response clears stale error on graded responses and stale incomplete_details on completed/failed responses. When the ladder reclassifies a selected failure, it preserves the original event as the cause of an agent.run event. An unknown outcome clears the selection instead, retaining all diagnostic events because unknown is not a canonical failure-event kind.

Harbor and single_agent_turn share agent_response_action. A matching selected report becomes the episode failure's cause; mismatches, unreadable selections, omitted reports and null reports fail. No report or an unselected report keeps the outcome policy. A status-less selected model-request error fails unless every attempt is proven never to have connected. The merge preserves #6013's connection-timeout handling and #5686's queue-timeout policy.

Compatibility and score impact

  • Defaults are model_context_limit: verify, agent_run_error: retry, and model_request_rejected: fail. OpenClaw's failed context overflow is now graded. Agentic-MME already overrides context limits to verify in its shipped YAML; default-only configurations now receive the same handling.
  • DeepAgents' task-caused runner termination now returns incomplete, without an error or failed outcome, so its partial work is graded rather than retried under the new agent_run_error default. Its sandbox observation still reports the failed execution. This is the targeted adapter behavior change in this PR.
  • Harbor now applies the report-consistency and unsent-request rules above, including the stricter omitted/null-report cases. A confirmed policy-response timeout follows Harbor's outcome policy (FAIL by default); single_agent_turn also consults the agent timeout rule (RETRY by default).
  • First-request model_request_rejected has no status, so overrides such as by_status_code: {404: retry} no longer match that outcome after migration. Use by_failure_kind: {model_request_rejected: retry}. The original status remains in the cause event when a report supplied it.
  • Conformance accepts both the ladder's rejection and the exact-status model_request_error during migration; test(conformance): add outcome-ladder scenarios #5873 owns removing that allowance. Wrong/missing/invalid statuses still fail the check.
  • A deployment that grades runs with no result can set by_failure_kind: {agent_run_error: verify}. The default deadline flip remains deferred until session-correlated model-call capture is available for all harnesses.

Related policy work: #5723, #5798, #5686 and #5032. This branch merges main with a merge commit, preserving shared history; no rebase or force push.

Validation

Linux workstation, Python 3.13.14, merged main's OpenAI 2.45.0. Full suites below ran on repair commit d7c1af12fb42cde125caf953d6d17f16ce9788fe. A concurrent merge advanced the published head to 94d20acf69ef5dff3c0c3616d77e1c0e09c9a7dd, adding only main's UI-generation environment; every repair file is unchanged. On that actual head, 178 focused tests and all-files pre-commit passed again, and CI is running.

  • pytest tests/unit_tests/agents tests/unit_tests/core tests/unit_tests/client/test_openai_client.py tests/unit_tests/rollouts/harness_capabilities scripts/harness_conformance/tests environment_servers/single_agent_turn/tests environment_servers/harbor/tests: 3,034 passed, 14 skipped.
  • DeepAgents full suite: 133 passed, including local-supervisor termination tests. Agentic-MME full suite: 106 passed.
  • Public API/facade and Fern-link suites: 1,140 passed, 24 subtests. Final outcome-response regression file: 46 passed.
  • Before/after: 25 regression cases fail against the merge commit before these fixes; the deeply nested JSON case separately reproduces RecursionError there and passes after repair.
  • Every remaining adapter/Environment Server suite was attempted with --continue-on-collection-errors: 6,555 passed, 72 skipped, 84 failed, 102 collection errors. All 84 executed failures reproduce on unchanged main with verified, isolated source imports; they are outside this repair. 96 collection errors also reproduce on isolated main; the other six collect after the missing image dependencies were installed. Agentic-MME was rerun successfully. Optional SDK/dependency limitations remain.
  • pre-commit run --files <all 26 PR paths> and pre-commit run --all-files: passed, including import-linter. DCO sign-off on both new commits.
  • npm run check / fern check --warnings: zero errors; one warning that authenticated redirect checking was skipped without a Fern token. No page paths or redirects changed.
  • Local evidence: /home/yuya/Projects/pr-flow/runs/20261117-011726-pr5870-fix/, including per-finding dispositions, test logs, baseline comparison, and the final summary.

Rollout evidence and next stage

Real-model smoke has not been run for this repaired head. This fix stage runs deterministic regression tests and Linux local-supervisor tests; these do not replace model/verifier evidence. The requested next stage is smoke: exercise a real-model OpenClaw context-overflow episode on single_agent_turn, a Harbor failed-turn episode, and DeepAgents' task-caused runner termination, inspect the agent/verifier behavior, then assess CI and rereview. The PR is marked ready for review at the author's explicit request; this evidence remains outstanding before merge.

Today the same event gets a different outcome in different harness adapters:
a context limit is graded in one and failed in another, "no usable result"
answers 500, 502, 503 or 200, and a model 4xx before any reply is graded,
retried or failed depending on the harness.

Add one ladder in nemo_gym/agents/agent_outcome.py. An adapter fills a
RunEvidence from its own parser and returns finish_response(response,
evidence); decide_outcome picks the first matching row (stopped, context limit,
deadline with a recorded infrastructure fault, deadline, error, limit, refusal,
result, no result). A model 4xx other than 408/425/429 before any model reply
becomes model_request_rejected for every harness. No adapter uses it yet.

Policy defaults: model_context_limit verifies (backstop for adapters that still
report a context limit as failed), agent_run_error retries (no usable result,
same disposition as today's 5xx), model_request_rejected fails.

Harbor's failed-response routing now shares single_agent_turn's checks
(agent_response_action): a failure_report that contradicts ng_agent_outcome
fails the episode, and the selected failure is the episode failure's cause and
kind. The conformance model_error check expects model_request_rejected, and
the harness guide documents the ladder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Nov 9, 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 feature New capabilities, enhancements, or enablement work area:agent Agent harnesses and Responses API agent behavior area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers labels Nov 9, 2026
A run the session's close cancelled is stopped too, and the ladder reports it
as incomplete, but the marker exists to tell a rollout stop apart from a
timeout or a cancellation. finish_response now writes it only when the run's
session expired (a rollout stop), and documents stopped as covering both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
…aw tests

Codex tests imported agent_outcome_policy through single_agent_turn.app, which
no longer imports it now that agent_response_action holds the routing; they
use the agents package's public API. OpenClaw's context-limit test pinned the
old FAIL default for a failed model_context_limit; the ladder's backstop
grades it, and an override can still fail it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
…rror_outcome

Scripted-model smokes of the migrated adapters showed a context overflow graded differently by harness.
Gym's model servers answer a context overflow they propagate with HTTP 400 and OpenAI's error envelope,
code `context_length_exceeded`. Adapters that read only the status reported it as `model_request_error` 400
(failed) or, before the first reply, `model_request_rejected` (never graded), against decision 1.

`model_http_error_outcome(status, error_body=...)` classifies a failed model request for
`RunEvidence.error`: a 400 whose body carries that code is `model_context_limit`, which the ladder answers
as `incomplete` before or after the first reply; any other failure stays `model_request_error` with its
status. The harness guide points adapters at it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33

Copy link
Copy Markdown
Contributor Author

/ok to test bb2e2fc

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

@yaoyu-33

Copy link
Copy Markdown
Contributor Author

/ok to test 94d20ac

@yaoyu-33

Copy link
Copy Markdown
Contributor Author

/ok to test d7c1af1

@yaoyu-33
yaoyu-33 marked this pull request as ready for review November 17, 2026 01:43
@copy-pr-bot

copy-pr-bot Bot commented Nov 17, 2026

Copy link
Copy Markdown

/ok to test d7c1af1

@yaoyu-33, there was an error processing your request: E2

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/

@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 17, 2026 01:43
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 17, 2026 01:43

@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

I inspected all 26 changed files and their directly affected contracts. This was a static review; I did not execute tests or verify the author's local test artifacts.

RISK: Representative real-model smoke evidence is missing

The PR description explicitly says real-model smoke has not run on this head. This changes grading eligibility through the shared policy defaults and DeepAgents termination handling. Deterministic regression tests do not satisfy the required representative model-and-verifier smoke validation.

Could you run the planned smoke cases on this head and attach the resolved configuration, runtime versions, rollout identifiers and inspected agent/verifier artifacts? Acceptance should show:

  • An OpenClaw context-overflow episode through single_agent_turn reaches verification with its partial output rather than failing ungraded.
  • A Harbor failed turn with a matching selected transport failure skips verification, stays retryable and keeps the selected event as its cause.
  • A task command that terminates DeepAgents returns incomplete, clears error, carries no failed outcome and proceeds to verification. Genuine provider failures and unconfirmed cleanup must still stay ungraded.

Keep the deterministic rejection, timeout and cleanup regression coverage; these smoke runs supplement it rather than replace it.

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

boundary=FailureBoundary.AGENT,
failure_kind=outcome.failure_kind,
http_status=outcome.status_code,
operation="agent.run",

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.

RISK: Reclassified policy timeouts lose the evidence required for routing

finish_response can turn a confirmed model timeout into a terminal consistency failure. Start with the existing _confirmed_policy_timeout() fixture, select its model event, and finish the response with RunEvidence(has_result=False, timed_out=False, model_replied=True, error=AgentOutcome(failure_kind="model_policy_response_timeout")). The new event gets operation="agent.run" and no operation_id. reported_agent_failure therefore rejects it, and agent_response_action returns FAIL even with a model_policy_response_timeout: verify override or a timeout callback that would retry. This affects adapters using the new helper to classify a raw model failure report.

Could you preserve the policy-timeout operation contract when the selected model event proves that timeout? Do not relax the consumer to accept arbitrary agent.run timeout claims. At this constructor, the following is a suggested replacement, not executed; verify it before adopting. It also needs imports for MODEL_POLICY_RESPONSE_TIMEOUT, POLICY_TIMEOUT_OPERATION and confirmed_policy_response_timeout from their defining modules:

confirmed_timeout = (
    outcome.failure_kind == MODEL_POLICY_RESPONSE_TIMEOUT
    and confirmed_policy_response_timeout(report)
)
event = FailureEvent(
    boundary=FailureBoundary.AGENT,
    failure_kind=outcome.failure_kind,
    http_status=outcome.status_code,
    operation=POLICY_TIMEOUT_OPERATION if confirmed_timeout else "agent.run",
    operation_id=selected.operation_id if confirmed_timeout else None,
    failure_reason=_FAILED_RUN_MESSAGES[decision.stop_reason],
    cause_id=report.failure_id,
)

This keeps the existing confirmation guard: only a selected model operation whose attempts all timed out after upload gains the correlated policy-timeout event. Other reclassifications still use agent.run, and unproven timeouts still fail consistency checks.

Proposed acceptance: add the setup above to the response regression tests. Assert that a verify override is honored, a supplied retry callback is invoked, and the rebuilt cause retains the model event. Finishing twice must not add another event. Retain the existing direct agent.policy_request callback case and generic reclassification/idempotence assertions. Missing-upload or mixed-attempt timeout reports must still return FAIL without invoking the callback.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Nov 17, 2026
yaoyu-33 added a commit that referenced this pull request Nov 18, 2026
…he merged ladder

After merging #5870, finish_response clears error on every graded response,
so the Hermes, Stirrup and BrowseComp context-overflow tests now assert that
an incomplete context-limit response has no error (Hermes keeps its own text
in metadata["hermes_error"]).

BrowseComp's session loop built its evidence from the reply's status alone,
so the stop reasons #6088 records were lost: a context_full length cut was an
output limit, and a run that hit max_steps without an answer was completed.
The evidence now reads the loop's stop_reason: context_full is a context
limit, max_output_tokens an output limit, and max_steps a turn limit, or, when
the run still has an answer, a result marked harness_step_limit_reached. A
failed response's error is a ResponseError instead of a plain dict.

Also cover Stirrup's missing-output guard, both Hermes truncation errors and
NOOA's limit rows (agent_limit vs output_limit).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>

This branch was previously deployed

1 inactive (outdated) deployment
public — bb2e2fce Deployed Nov 10, 2026 by copy-pr-bot[bot] via release / finalize / notify #11246
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 area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants