Repository navigation
Conversation
Harness-side model retries may cover only 408, 425, 429, 5xx and transport errors, with a bounded total wait. OpenCode 1.17.11 resends a failed model request with no attempt or time limit, also after a 409, and waits exactly as long as Retry-After says. Against a persistent 503 with Retry-After: 0 it sent about 360 requests in 38 s until the run deadline, so the episode was graded as incomplete instead of failed and retried. Kilo Code 7.4.15 did the same (about 330 requests); its only setting is an attempt count. Neither CLI can be configured for this, so a plugin (opencode_agent/model_retry_limit.mjs, shared with Kilo) wraps the fetch of every configured provider: a 408, 425, 429 or 5xx reaches the CLI with retry-after-ms set to Retry-After capped at 10 s (else 1 s, 2 s), and a 409 or the third failure in a row ends the turn with "NeMo Gym model retry limit: HTTP <status> ...". The adapters classify that error as model_request_error with the status (or model_transport_error), so the Environment Server's outcome policy applies as for an API error. OpenCode loads the plugin locally (with a model server) and in sandbox sessions; Kilo loads it in sandbox sessions and also sets KILO_SESSION_RETRY_LIMIT=2, the only bound on its local --pure run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
This was referenced Nov 10, 2026
Contributor
Author
|
/ok to test 71e465a |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
OpenCode 1.17.11 (read from
anomalyco/opencodeatv1.17.11) wraps each model attempt in a retry policy with no attempt and no time limit. It resends anything the AI SDK marks retryable (408, 409, 429, ≥500), any 5xx, transport errors and rate-limit texts. It waits exactly as long asretry-after-ms/Retry-Aftersays, uncapped, soRetry-After: 0makes a hot loop. Against a persistent 503 it sent about 360 requests in 38 s until the run deadline, and the episode was gradedincompleteinstead of failing with the 503 and being retried. Kilo Code 7.4.15 (an OpenCode fork) did the same (about 330 requests). Its only setting isKILO_SESSION_RETRY_LIMIT, an attempt count that still resends a 409 and still follows anyRetry-After. OpenCode has no setting at all.So this adds a plugin,
opencode_agent/model_retry_limit.mjs, shared with Kilo. Itsconfighook wraps thefetchof every provider in the config:retry-after-msset toRetry-Aftercapped at 10 s (else 1 s, then 2 s), so the CLI's own loop resends it;NeMo Gym model retry limit: HTTP <status> after 3 attempts(orHTTP 409 is not sent again, orno model response after 3 attempts). It is a plainError, because both CLIs resend every 5xx API error. Its text and its missingcausekeep both CLIs from reading it as a rate limit or a lost connection, which they would also resend;The CLIs save that error as an
UnknownError.retry_limit_outcome(shared inopencode_agent/runtime.py) classifies it asmodel_request_errorwith the status, ormodel_transport_error. OpenCode's sandbox path treats it as a reported model error (HTTP 200failed) as it does an API error, and Kilo's error event path does the same. So the Environment Server's outcome policy applies as for an API error.Where it loads:
model_serverdefines Gym's provider, and in every sandbox session (uploaded besidetask_environment.mjs, also for a continuation);KILO_SESSION_RETRY_LIMIT=2, which is the only bound on the local run: it starts Kilo with--pure, which loads no plugins. There a 409 is still resent twice and a serverRetry-Afteris followed in full (documented in the README).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; NOOA, Hermes and Stirrup).
opencode_sandboxed_agent, which is being retired, is not changed.Related: #5910 (NOOA, Hermes, Stirrup), #5911 (Claude Code), #5912 (Codex), #5913 (OpenCode, Kilo Code).
Score and compatibility impact
model_request_errorand that status. The Environment Server retries it, instead of the run spinning until its deadline and being gradedincomplete(OpenCode) or failing asunknown(Kilo).openai_base_urlwithoutmodel_server) defines no provider in the config and keeps OpenCode's own retries.Validation
Linux workstation, each adapter's
uv sync --frozenvenv, Node 22.19.0:opencode_agent/tests: 865 passed, 8 skipped. 1 failed,test_pinned.py::test_stage_executable_rejects_wrong_or_broken_bytes_without_installing[format], which this PR does not touch: the host's/bin/shis dash, which reports an unexecutable file as exit 2 where the test expects 126.kilocode_agent/tests: 256 passed, 7 skipped.test_model_retry_limit.pydrives the plugin under Node:retry-after-ms, then end the turn;Retry-After: 60gives 10 s, and no header gives 1 s then 2 s;cause;configcall does not wrap twice, and the module exports only the plugin.model_request_error503/409 andmodel_transport_error(OpenCode and Kilo). The host config loads the plugin with a model server, and Kilo's local environment sets the count. Tests that pinned the exact plugin list and uploads now include the plugin.pre-commit run --files <changed files>: passed. Commit 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:
model_error(persistent 400),model_401,model_503,retry_429(two 429s, then success),retry_500(one 500, then success),context_overflow. The scripted endpoint answers every error withRetry-After: 0.ng_agent_outcome→ Environment Server action.model_503outcome.ladder,outcome.disposition,model.retries_bounded,model.terminal_errorfailmodel_request_error503 → retry; every P0 check passesmodel_503unknown→ retry; the same four P0 checks failmodel_request_error503 → retry; every P0 check passesmodel_error,model_401model_request_rejected→ failretry_429,retry_500context_overflowOpenCode's B row is from a re-run after the plugin started keeping the server's error message in its final error; before that,
model.terminal_errorfailed on the missing message.Real-model rollouts: not run yet; this PR stays a draft until they are.
🤖 Generated with Claude Code