Skip to content

refactor(agent): move Pool and LangGraph to the outcome ladder - #5880

Draft
yaoyu-33 wants to merge 8 commits into
feat/agent-outcome-ladderfrom
refactor/outcome-ladder-pool-langgraph
Draft

yaoyu-33 wants to merge 8 commits into
feat/agent-outcome-ladderfrom
refactor/outcome-ladder-pool-langgraph

Conversation

@yaoyu-33

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

Copy link
Copy Markdown
Contributor

Stacks on #5870 (the shared outcome ladder). The base is feat/agent-outcome-ladder, so this diff shows only Pool and LangGraph. Merge #5870 first. It is independent of the Hermes/Stirrup/BrowseComp/NOOA PR; the two were split to keep each under about 1,000 changed lines.

What changed and why

Neither adapter classified a model error. Pool raised every model error, a deadline before any reply, and a run without a result as a 500 that lost the status. LangGraph answered every model error with a 500.

Each now fills a RunEvidence and returns finish_response(...) with HTTP 200.

  • Pool (pool_agent/sandbox_runner.py, sandbox.py, app.py)
    • The in-sandbox model proxy now records, in model_calls.json, how the last model call failed: its HTTP status and the first 4 KB of its body, or transport when no reply came. A later completed call clears it.
    • A model_next_tool_call_http_error exit is classified from that record through the shared model_http_error_outcome: model_request_error with the status, model_context_limit for a 400 whose body is the model server's context-overflow envelope (code context_length_exceeded), model_transport_error, or unknown without a record. Pool's own events carry no status.
    • A session.error is unknown (decision 5). A run that exits without exit_tool_called, with a bad exit code or with an incomplete trajectory is agent_run_error.
    • Deadline. It is graded after a reply. Before one, it stays retried (retry_deadline_before_reply=True). A reply is a completed model call in the proxy record or any model output in the trajectory.
    • Infrastructure evidence for a deadline (the rule). When the receipt says the deadline ended the run, and the proxy's record says the last model call failed with 408/425/429/5xx or got no reply (with no completed call after it), the deadline was spent on a failing model server. That record becomes infra_fault, and the run fails with that kind and is retried. A 4xx other than 408/425/429 is not infrastructure evidence.
    • A failed response keeps its failure artifacts, as the raised failure did.
    • An unconfirmed cleanup, a supervisor error, and an unreadable or malformed trajectory still raise. The exception is an unreadable trajectory under a deadline before any reply, which goes through the ladder.
  • LangGraph (langgraph_agent/app.py)
    • The graph runs on its values stream; the last value is what ainvoke returned.
    • A model call that fails after Gym's client retries ends the run with the outputs of the steps that finished. It is classified by model_http_error_outcome from its status and the error body Gym's client keeps (response_content), or as model_transport_error. A propagated context overflow is therefore a graded incomplete context limit, with no error on the response. Parallel paths whose failures are all model errors report the first one.
    • A confirmed policy response timeout still raises its typed failure, as before. Any other exception stays the adapter's 500.

A model 4xx other than 408/425/429 before any model reply is now model_request_rejected for both (decision 4).

Tests that pinned main's raises (pool_agent/tests/test_app.py, the old 868-893 and its neighbours) are updated, with the reason in the test. New tests cover:

  • the proxy record (status and transport);
  • classification from it;
  • the infrastructure-fault rule, and the 4xx that is not one;
  • LangGraph's status, transport and parallel-path errors;
  • LangGraph's completed response.

Issue: none; this is part of the step 1 migration that #5870 starts.

Disposition changes

Source of each "main" cell: code reading of main acb67734cc (pool_agent/app.py _activate, langgraph_agent/app.py _invoke_graph), cross-checked against main's tests in parentheses.

Events: a context overflow (vLLM's propagate flag on) · b deadline before any reply · c deadline after a reply · d no usable result · e persistent 429/5xx · f 401 · g other 4xx before any reply · h refusal. ★ marks a row whose action changes.

Harness Event main: HTTP, status, ng_agent_outcome → action this PR → action
Pool ★ a (before or after a reply) 500, status lost → retry (test_runtime_failure_is_not_returned_as_a_gradable_response) 200 incomplete → verify
Pool b 500 → retry (test_timeout_without_trajectory_requires_completed_model_response) 200 failed unknown → retry
Pool c 200 incomplete → verify (test_confirmed_timeout_keeps_partial_output_gradable) same
Pool ★ c, the last model call failing 429/5xx or transport, Pool still retrying 200 incomplete → verify 200 failed with that kind (infra_fault) → retry
Pool c, a recorded model-error exit 500 → retry (test_recorded_model_failure_overrides_timeout_and_preserves_diagnostics) 200 failed with the recorded kind → retry
Pool ★ c, a session.error or unknown exit reason 500 → retry (test_timeout_does_not_hide_unknown_terminal_failure) 200 incomplete → verify (the deadline ended the run)
Pool d 500 → retry (test_runtime_errors_cannot_be_disguised_as_gradable_partials) 200 failed agent_run_error → retry
Pool e (also transport) 500, status lost → retry 200 failed model_request_error status / model_transport_error → retry
Pool ★ f 500 → retry 200 failed 401 / rejected → fail
Pool ★ g 500 → retry 200 failed model_request_rejected → fail
Pool h completed → verify same
LangGraph ★ a (before or after a reply) 500 → retry (test_graph_optional_grants_and_failed_activation_close pins the 500) 200 incomplete → verify
LangGraph b, c no deadline; the episode timeout retries same (gap below)
LangGraph d (an exception that is not a model error) 500 → retry same
LangGraph e (also transport) 500 → retry 200 failed model_request_error status / model_transport_error → retry
LangGraph ★ f 500 → retry 200 failed 401 / rejected → fail
LangGraph ★ g 500 → retry 200 failed model_request_rejected → fail
LangGraph h completed → verify same

Scores change for:

  • A context overflow, and any other 400 after a reply: retried → graded (Pool, LangGraph).
  • 401 and other 4xx: retried → failed (Pool, LangGraph).
  • Pool's deadline after a reply: graded → retried when the model server was failing; retried → graded when Pool only logged a session.error or an unknown exit.

Gaps left for step 5 (deadlines)

LangGraph has no deadline of its own: the episode timeout cancels it and the episode is retried. No budget is invented here.

Validation

Run on macOS against the worktree (LangGraph with langchain-core==1.7.3 and langgraph==1.2.18 on the path):

  • Pool, LangGraph and tests/unit_tests/agents/test_outcome_ladder.py: 248 passed, 12 skipped.
    • The skips are Pool's parametrized lifecycle tests that need the Linux process supervisor, plus one test that needs a Pool binary (POOL_TEST_BINARY). They did not run here.
  • Later commits, run on a Linux host against the previous head, with LangGraph in its locked venv:
    • LangGraph: 54 → 57 passed (the context-limit tests), then 57 → 57 after it moved to the shared helper.
    • Pool: 156 → 159 passed, 2 skipped. This run also covered the Linux-only lifecycle tests. One of them still expected the old RuntimeError for a deadline on a stalled model call, and it now expects the ladder's answer: failed model_transport_error, retried, because the proxy recorded the stall as a transport failure.
  • pre-commit run --files <touched>: passed.

Smoke evidence

Scripted-model smoke of LangGraph (reflection agent) on a Linux host, with no real model. A driver ran the session routes (seed, activation with the session cookie, close) in front of Gym's real vllm_model (propagate_context_overflow_errors: true) and a scripted upstream. The action is what agent_response_action returns under the default policy.

Event A B B′
ok 200 completed → verify same same
400 on the first request 500 → retry 200 failed model_request_rejected → fail same
400 after a reply 500 → retry 200 failed model_request_error 400 → verify same
401 500 → retry 200 failed model_request_rejected → fail not rerun
503 500 → retry 200 failed model_request_error 503 → retry (3 upstream calls, all vllm_model's) not rerun
context overflow, first request 500 → retry 200 failed model_request_rejected → fail 200 incomplete, no error → verify
context overflow after a reply 500 → retry 200 failed model_request_error 400 → verify 200 incomplete, no error → verify

Counts over these 7 events: A verify 1, retry 6. B′ verify 4, retry 1, fail 2. The deadline and kill events do not apply: LangGraph has no deadline of its own and no separate harness process.

Pool was not run. Its install accepts Poolside's EULA (accept_pool_eula), which needs the user's own consent. Pool's rows above come from the tests, not a smoke.

🤖 Generated with Claude Code

yaoyu-33 and others added 2 commits November 9, 2026 11:36
Neither adapter classified a model error. Pool raised every model error, a
deadline before any reply and a run without a result as a 500 that lost the
status; LangGraph answered every model error with a 500.

Each now fills a RunEvidence and returns finish_response with HTTP 200.

- Pool: the in-sandbox model proxy records how the last model call failed (its
  HTTP status, or a transport error) until a later call completes. A
  model_next_tool_call_http_error exit is classified from that record. A
  deadline is graded after a reply and stays retried before one; a deadline
  while the last model call had failed with 408/425/429/5xx or got no reply is
  that infrastructure fault (retried). A launch, supervisor or unreadable
  trajectory failure still raises.
- LangGraph: the graph runs on its values stream, so a model call that fails
  after Gym's client retries ends the run with the finished steps' outputs,
  classified by its status or as a transport error. A confirmed policy
  response timeout keeps its typed failure, and other exceptions stay the
  adapter's 500.

A model 4xx other than 408/425/429 before any model reply is now
model_request_rejected for both.

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.

…t limit

With `propagate_context_overflow_errors` on, Gym's model server answers a context overflow with HTTP 400
and OpenAI's error envelope, code `context_length_exceeded`, which `raise_for_status` keeps on the error as
`response_content`. LangGraph reported it as `model_request_rejected` on the first request (failed) and
`model_request_error` 400 after a reply. It is now `model_context_limit`, so the outcome ladder answers
`incomplete` and the run is graded, before or after the first reply (decision 1). An incomplete response
no longer carries the model call's error. A 400 with another code stays a model request error.

Found by a scripted-model smoke through Gym's vLLM model server.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
yaoyu-33 and others added 2 commits November 9, 2026 16:16
…tp_error_outcome

The shared helper replaces LangGraph's own reading of the model server's error envelope. Behavior is
unchanged: a propagated context overflow is still a graded `incomplete` context limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Pool's events carry no HTTP status, so its model proxy records how the last model call failed. It kept
only the status, so a context overflow the model server propagates (HTTP 400, OpenAI code
`context_length_exceeded`) was `model_request_rejected` on the first request and `model_request_error`
400 after a reply. The proxy now also keeps the first 4 KB of the failed reply's body, and
`classify_outcome` passes it to the shared `model_http_error_outcome`. The overflow is then
`model_context_limit`: `incomplete` and graded, before or after the first reply (decision 1).

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

This Linux-only lifecycle test still expected the RuntimeError (HTTP 500) that a deadline before any
model reply raised before the outcome ladder. Pool's proxy records the stalled call as a transport
failure, so the ladder answers HTTP 200 failed `model_transport_error`, which is retried. The test was
skipped on macOS, where the earlier runs of this PR's tests were made.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@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 — 8643885c Deployed Nov 10, 2026 by yaoyu-33 via release / finalize / notify #11249
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