Skip to content

refactor(agent): move Simple Agent onto the outcome ladder - #5907

Draft
yaoyu-33 wants to merge 1 commit into
feat/agent-outcome-ladderfrom
refactor/simple-agent-outcome-ladder
Draft

yaoyu-33 wants to merge 1 commit into
feat/agent-outcome-ladderfrom
refactor/simple-agent-outcome-ladder

Conversation

@yaoyu-33

Copy link
Copy Markdown
Contributor

Stacks on #5870 (the shared outcome ladder). Review the diff against feat/agent-outcome-ladder; it touches only Simple Agent.

What changed and why

Simple Agent is the harness-conformance reference, but no adapter PR moved it onto the ladder. Its agent-session error path built the failed NeMoGymResponse and wrote ng_agent_outcome by hand, so every model HTTP error was model_request_error with its status. That misses two team decisions the ladder already applies to the other harnesses:

  • Decision 4: a model 4xx other than 408/425/429 before any model reply is model_request_rejected (failed, neither graded nor retried).
  • Decision 1: a context overflow that the model server propagates is incomplete and graded.

As a result Simple Agent failed the conformance model.terminal_error check on model_error and model_401, and the calibrated model_error health expectation.

responses_api_agents/simple_agent/app.py (session path of _create_episode, the except ClientResponseError block):

  • Builds RunEvidence(has_result=False, timed_out=False, model_replied=..., error=...) and returns self.finish_response(response, evidence).
  • error is model_http_error_outcome(error.status, error_body=<response content>) for an HTTP error, and AgentOutcome(model_policy_response_timeout) when the reply shows a confirmed policy-response timeout.
  • model_replied is whether an earlier step of the loop got a model reply (step > 1). Each step calls the model once and continues only after its reply. A restored boundary keeps its step, so restored steps count. It is per activation, like the other adapters' per-run evidence. In a multi-activation session, a rejected first call of a later activation is therefore model_request_rejected.
  • Rejected requests and the failure_report: the Environment Server takes the failure that the reply's failure_report selects as the episode failure's cause and kind, and it treats a selected failure that contradicts ng_agent_outcome as inconsistent evidence. For a rejected request, Simple Agent now selects an agent-boundary model_request_rejected failure caused by the model error. This is the same pattern its policy-timeout path already uses. Without it, the failure row would have no kind (environment_server_failed), as the A run below shows for model_401. The report's construction (reply_report / report_for_current_request) and the merge of the model server's forwarded report are unchanged.
  • The trajectory invocation follows the response's status. Its error_type still names the error the run ended on (model_request_error, model_context_limit or model_policy_response_timeout).
  • Zero aggregate usage is still reported only when no model call succeeded. The condition now reads not model_replied, which is the same as the old step == 1.
  • Unchanged: the policy-timeout path, the legacy /run path (it still raises), Simple Agent's own retries (max_model_retries for 408/425/429/5xx only, which is decision 6), and the body-failure and unreadable-report raises.

responses_api_agents/simple_agent/README.md describes the session outcomes.

Tests (responses_api_agents/simple_agent/tests/test_app.py). The old test_terminal_model_http_error_returns_cause_and_zero_usage pinned model_request_error for 400/401/422. It is replaced by per-event tables. Each case asserts the response status, ng_agent_outcome, ng_agent_stop_reason, the default Environment Server action and recorded failure kind (agent_response_action with AgentOutcomePolicyConfig()), the endpoint's message, the usage and the invocation:

  • before any reply: 400/401/422 → rejected/fail; 429/503 → model_request_error N/retry; a context overflow → incomplete/verify. Each case runs with and without the model server's forwarded report.
  • after a reply: 400 → verify, 401 → fail, 503 → retry, context overflow → incomplete/verify. The partial work and usage are kept.
  • a session policy timeout keeps its typed failure (model_policy_response_timeout, agent-boundary selected failure).

Score and disposition changes

The main column comes from code reading at bb2e2fced5. Simple Agent is the same there as on main, and #5870 does not touch it. (t) marks a row that a test on the base pins, and (s) a row the A conformance run below shows. Actions: verify = graded, retry = episode retried up to the attempt cap, fail = neither. Rows marked changed change disposition.

Event main this PR
context overflow the model server propagates (400 context_length_exceeded), before or after a reply 200 failed model_request_error 400 → verify (s) 200 incomplete → verify outcome only (decision 1)
context overflow, default vLLM length path (empty completion) 200 incomplete → verify (s) same
deadline before / after any reply n/a: Simple Agent has no run deadline (conformance LACKS) same
confirmed policy-response timeout 200 failed model_policy_response_timeout → Environment Server timeout rule same (ng_agent_outcome no longer serializes a null status_code)
no usable result n/a: runs in the Agent Server process; an unexpected exception answers 500 → retry same
persistent 429/5xx (after max_model_retries) 200 failed model_request_error N → retry (t)(s) same
401/403/404 before any reply 200 failed model_request_error 401 → fail; failure row has no kind (t)(s) 200 failed model_request_rejected → fail; row kind model_request_rejected outcome only (decision 4)
other 4xx before any reply (400, 413, 422) 200 failed model_request_error 400 → verify (graded, reward 0) (t)(s) 200 failed model_request_rejected → fail changed (decision 4)
4xx after a reply 200 failed model_request_error N → verify (400/413/422) or fail (401/403/404) same
refusal no refusal signal: the refusal is the final answer, completed → verify same
legacy /run model error raises (typed policy timeout or the HTTP error) same

Validation

All heavy work ran on a Linux workstation (Python 3.13.14). Nothing heavy ran on the Mac.

  • pytest responses_api_agents/simple_agent/tests: 168 passed. Against the base app.py, 14 of the 17 new cases fail. The 3 that pass are the unchanged after-reply 400/401/503 rows.

  • Neighbouring suites: environment_servers/single_agent_turn/tests, simple_agent_with_compaction, agentic_turn_simulation_agent, non_executing_simple_agent, labbench2_vlm_agent, tests/unit_tests/agents, tests/unit_tests/rollouts/test_rollout_collection.py and test_simple_agent_body_store.py. All passed except two that the test environment cannot run: test_outcome_policy.py::test_upload_evidence_roundtrips_* needs cloudpickle, which the venv lacks (same failure without this PR), and gdp_pdf_agent needs PIL. Its tests mock _create_episode.

  • pre-commit run --files on the three touched files: passed.

  • Harness conformance, A/B, scripted model (no real model), local servers, concurrency 1. A = test(conformance): add outcome-ladder scenarios #5873 head 90a4af722c (conformance scenarios, which contains feat(agent): add the shared outcome ladder for harness runs #5870 bb2e2fced5). B = A merged with this PR, with no conflicts; the trees differ only in the two Simple Agent files.

    python scripts/run_harness_conformance.py --harness simple --scenario model_error --scenario model_401 --scenario context_overflow --scenario model_503 --timeout 150 --output <dir>
    python scripts/run_harness_conformance.py --harness simple --timeout 150 --output <dir>

    Required scenarios: A exit 1, B exit 0 (P0 passes). Full Simple Agent suite: A exit 1, B exit 0.

    Scenario A B P0 A → B
    model_error 200 failed model_request_error 400 → verify, reward 0; model.terminal_error ✗, health.rollout_token_count_mismatch ✗ 200 failed model_request_rejected → fail, row kind model_request_rejected; E ✓ ✗ → ✓
    model_401 200 failed model_request_error 401 → fail, row kind none; outcome.ladder ✗, outcome.disposition ✗, E ✗ 200 failed model_request_rejected → fail, row kind model_request_rejected; H ✓ L ✓ D ✓ E ✓ ✗ → ✓
    context_overflow 200 failed model_request_error 400 → verify, reward 0; outcome.target (P1) ✗ 200 incomplete → verify, reward 0; H ✓ L ✓ D ✓ T ✓ ✓ → ✓
    model_503 200 failed model_request_error 503 → retry; R ✓ E ✓ same ✓ → ✓
    other 9 (tool_success, tool_failure, usage_omitted, retry_429, retry_500, context_overflow_length, judge_verifier, verifier_failure, context_compaction) same status, action and reward on both same ✓ → ✓

    deadline_before_reply, deadline_after_reply and harness_no_result do not apply to Simple Agent (no run deadline, no harness process).

Rollout evidence

Scripted-model conformance only (above). The scripted provider drives each error through the real Gym model server, Simple Agent, single_agent_turn_legacy and rollout collection. A real-model run is N/A: the change is confined to the model-HTTP-error branch, which a working model endpoint never takes, and the successful scenarios are unchanged in the A/B above.

Notes and leftovers

  • Not changed here: a model_request_error failure row (for example 503) still carries no failure kind on both A and B. Simple Agent's reply report selects nothing for a plain HTTP error, so the Environment Server takes the action from ng_agent_outcome alone and records environment_server_failed. Selecting a matching failure for every failed outcome would fix that and is a separate change.
  • simple_agent_with_compaction and agentic_turn_simulation_agent override _create_episode and do not use this path. Neither builds ng_agent_outcome.
  • Merge order: after feat(agent): add the shared outcome ladder for harness runs #5870. test(conformance): add outcome-ladder scenarios #5873's model_error scenario expects model_request_rejected, which Simple Agent now reports.

🤖 Generated with Claude Code

Simple Agent, the harness-conformance reference, built its failed session response and its
ng_agent_outcome by hand: every model HTTP error was model_request_error with its status. It
therefore missed two team decisions the ladder applies to the other harnesses: a 4xx other than
408/425/429 before any model reply is model_request_rejected (failed, not retried), and a context
overflow the model server propagates is incomplete and graded.

The session error path now fills RunEvidence and returns finish_response: the error is
model_http_error_outcome(status, error_body=...) for an HTTP error and the typed
model_policy_response_timeout otherwise, and model_replied is whether an earlier step of the loop got
a model reply. For a rejected request the reply's failure_report selects an agent failure of that
kind, caused by the model error, as it does for the policy timeout, so the Environment Server records
model_request_rejected on the failure row; a report that selected the model's HTTP error would
contradict the outcome. The report's construction and merging, the policy-timeout path and the
legacy /run path are unchanged. The README describes the session outcomes.

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 10, 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.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added support User questions, support, or maintenance requests area:agent Agent harnesses and Responses API agent behavior labels Nov 16, 2026

This branch was previously deployed

1 inactive deployment
public — d74a1be9 Deployed Nov 10, 2026 by yaoyu-33 via release / finalize / notify #11270
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 support User questions, support, or maintenance requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants