Skip to content

fix(agent): stop NOOA, Hermes and Stirrup from resending rejected model requests - #5910

Draft
yaoyu-33 wants to merge 1 commit into
mainfrom
fix/harness-model-retry-rejections
Draft

yaoyu-33 wants to merge 1 commit into
mainfrom
fix/harness-model-retry-rejections

Conversation

@yaoyu-33

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

Copy link
Copy Markdown
Contributor

What and why

The team's rule for harness-side model retries: resend a failed model request only after a 408, 425, 429, 5xx or a transport error, never after any other 4xx, and keep the total wait bounded. The Model Server already retries its own upstream, and the Environment Server retries the episode after a retryable failure. Scripted-model smokes found three adapters breaking the rule in retry loops that Gym controls:

Harness Before Cause Change
NOOA a 400 and a 401 sent 10 times CodeAct (pinned labs-OO-Agents 19caab16) calls the model again after any error, up to its consecutive-error limit; only ReasoningReplayError escapes gym_llm remembers a 4xx other than 408/425/429 and fails every later call of the rollout with the same error before sending anything. A context-window 400 is left alone: NOOA archives events and shrinks the reply budget, so its next request is smaller.
Hermes (hermes_agent, pinned 26bb847a) a plain 400 sent 3 times; the OpenAI SDK underneath also resends a 409 _is_generic_400 reads body["error"]["message"], but the OpenAI SDK has already unwrapped the body, so every SDK 400 counts as a transient "generic 400" New install_model_retry_policy: the SDK's own retries are off (max_retries=0, which every per-request client copies), and a 4xx other than 408/413/425/429 reaches Hermes as ModelRequestRejected, a ValueError that keeps the SDK error's text, status, body and response. Hermes ends the run on a ValueError after its context-length and 413 compression checks, so those still compress and resend a smaller request. Installed on the host and sandbox paths and on delegated children.
Hermes sandboxed (hermes_sandboxed_agent, Hermes v0.21.1) a generic 404 retried; any Retry-After honoured up to 600 s native classifier agent.api_max_retries: 1 (Hermes's own setting; 1 = one attempt). Compression restarts leave the retry loop and start a new count, so they are unaffected.
Stirrup a 409 resent twice; each retry waits out Retry-After up to 60 s the OpenAI SDK client Stirrup builds (max_retries=2); Gym's client overrides Stirrup's own tenacity-wrapped generate Gym's client now uses an AsyncOpenAI subclass that resends only 408, 425, 429 and 5xx (and, as before, connection errors), and caps each wait at 10 s, so its two retries wait at most 20 s.

The rule is Gym's existing is_retryable_dependency_status (408, 425, 429, 5xx) where nemo_gym is importable; Stirrup's in-sandbox runner and Hermes's stdlib-only helper spell out the same set.

Issue: no public issue; this implements the retry rule the team agreed for all harnesses. The other harness groups are in separate PRs (Claude Code, Codex, OpenCode and Kilo Code).

Related: #5910 (NOOA, Hermes, Stirrup), #5911 (Claude Code), #5912 (Codex), #5913 (OpenCode, Kilo Code).

Score and compatibility impact

  • A rejected request (400, 401, 403, 404, 409, 413, 422) now ends the run after one attempt instead of 3 to 10 identical or near-identical attempts. The reported outcome (status code, error text, model_rejected termination for NOOA) is unchanged, so the Environment Server takes the same action, sooner.
  • NOOA can no longer recover from a rejected 4xx by calling again with its error note appended (a pinned test asserted that recovery; it now asserts one request and MODEL_REJECTED). A 408 or 5xx still recovers.
  • Hermes no longer resends 429/5xx inside the SDK (it still does in its own loop: 3 attempts, 2 s and 4 s apart), so a persistent 503 is 3 requests instead of 9.
  • Hermes sandboxed no longer retries a 429 or 5xx in Hermes; the Model Server and the Environment Server's episode retry cover those.

Validation

Linux workstation, each adapter's own uv sync --frozen venv, from the repository root:

  • nooa_agent/tests: 786 passed. 1 failed, test_runtime_installer.py::test_warm_check_uses_private_scratch_without_writing_read_only_runtime, only because the run's TMPDIR was on /dev/shm; with TMPDIR elsewhere that file passes (10 passed).
  • hermes_agent/tests: 387 passed (the real pinned Hermes runtime: a 400, 401, 404, 409 and 422 each reach the model server once).
  • hermes_sandboxed_agent/tests: 82 passed.
  • stirrup_agent/tests: 190 passed (an httpx.MockTransport counts the requests: 400/401/404/409/422 sent once; 408, 425, 429, 500, 503 sent three times; Retry-After: 60 waits 10 s).
  • Updated tests that pinned the old resends, with the reason in a comment: NOOA test_model_rejection_preserves_original_provider_error, test_model_rejection_obeys_environment_policy_and_closes, test_worker_result_and_checkpoint_preserve_model_status, test_successful_model_retry_clears_rejection (now split into a 408/503 recovery test and a 4xx sent-once test); Hermes test_sandbox_rejection_preserves_runtime_token_totals.
  • pre-commit run --files <changed files>: passed. Commits are signed off.

Smoke evidence

Scripted-model smoke (no real model), Linux workstation, 2026-11-09, with the harness-conformance runner, one job at a time:

Harness Scenario A B
NOOA model_error 10 × 400, 1.6 s → failed model_request_rejected → fail 1 × 400, 1.4 s → same
NOOA model_401 10 × 401, 1.7 s → failed model_request_rejected → fail 1 × 401, 1.4 s → same
NOOA model_503 10 × 503, 1.7 s → failed model_request_error 503 → retry same (10 × 503, 1.8 s; a 5xx may be resent)
NOOA retry_429, retry_500 completed → verify same
NOOA context_overflow 1 × 200, then 10 × 400, each a smaller archived request → incomplete → verify same
Hermes model_error 3 × 400, 6.8 s → failed model_request_rejected → fail 1 × 400, 0.7 s → same
Hermes model_401 1 × 401 → failed model_request_rejected → fail same
Hermes model_503 9 × 503, 11.0 s → failed model_request_error 503 → retry 3 × 503, 6.8 s → same
Hermes retry_429, retry_500 completed → verify same (retry_429 10.1 s instead of 5.0 s: Hermes's own 2 s and 4 s waits replace the SDK's immediate resends)
Hermes context_overflow incomplete → verify same
Stirrup all six 400 and 401 once; 503 three times, 2.0 s; 429/500 recovered; context overflow incomplete same (no scenario sends a 409)

Every P0 check passes on B for NOOA, Hermes and Stirrup in all six scenarios. hermes_sandboxed_agent is not in the conformance registry and was not smoked.

Real-model rollouts: not run yet; this PR stays a draft until they are.

🤖 Generated with Claude Code

…el requests

Harness-side model retries may cover only 408, 425, 429, 5xx and transport
errors, with a bounded total wait. Three adapters broke that in loops Gym
controls:

- NOOA: CodeAct calls the model again after any error, up to its
  consecutive-error limit, so a 400 or 401 was sent ten times. Gym's model
  client now remembers a 4xx other than 408/425/429 and fails every later
  call of the rollout with it before sending anything. A context-window 400
  is left alone: NOOA archives events and shrinks the reply budget, so its
  next request is smaller.
- Hermes (pinned 26bb847a): its loop treats every OpenAI SDK 400 as a
  transient "generic 400" (it reads the message one level deeper than the
  SDK keeps it) and resends it three times; the SDK under it also resends
  409. The SDK's own retries are off now, and a 4xx other than
  408/413/425/429 reaches Hermes as a ValueError, which it does not retry.
  The sandboxed adapter (Hermes v0.21.1) sets agent.api_max_retries to 1.
- Stirrup: the OpenAI SDK client resent a 409 and followed a Retry-After of
  up to 60 s per retry. Gym's client now resends only 408, 425, 429 and 5xx
  and waits at most 10 s before each of its two retries.

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.

@yaoyu-33

Copy link
Copy Markdown
Contributor Author

/ok to test 960f60f

@svcnvidia-nemo-ci svcnvidia-nemo-ci added bug Something isn't working area:agent Agent harnesses and Responses API agent behavior labels Nov 16, 2026

This branch was previously deployed

1 inactive deployment
public — 960f60fe Deployed Nov 10, 2026 by copy-pr-bot[bot] via release / finalize / notify #11283
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants