Skip to content

feat(opencode): upgrade opencode_agent to OpenCode 1.19.6 and 2.3.2 - #6456

Merged
yaoyu-33 merged 7 commits into
mainfrom
codex/upgrade-opencode-v1-v2
Nov 25, 2026
Merged

yaoyu-33 merged 7 commits into
mainfrom
codex/upgrade-opencode-v1-v2

Conversation

@yaoyu-33

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

Copy link
Copy Markdown
Contributor

Summary

Upgrade opencode_agent's default OpenCode 1 CLI from 1.17.11 to 1.19.6. Select 2.3.2 explicitly with opencode_version: "2.3.2", replacing 2.2.7 as the supported OpenCode 2 pin. The sandbox installer receives the upstream SHA-256 of each Linux x64-baseline and arm64 asset, glibc and musl, for 1.19.6, 2.3.2 and now also 1.17.11, so every pinned release download is checked. The v1 host installer uses the exact npm version and the v2 host installer checks the release archive and executable version.

Unpinned configs follow the current upstream releases. Both generic OpenCode training examples inherit the shared default. Recipes that ship a fixed CLI or plugin bundle, or whose recorded results depend on 1.17.11, pin it. The old v2 download digests and 1.17.11 request sampling remain available for explicit pins. An upgrade of those benchmark images would need its own qualification. No separate issue is needed for this routine update to the two release lines introduced in #6001.

Review fixes (November 19)

  • Recipes pinned to 1.17.11. These configs keep the release their assets or results are tied to:
    • opencode_sandboxed_agent/configs/opencode_sandboxed_agent.yaml and the opencode_search example. The deprecated agent's plugins and stable-date capture were checked on 1.17.11; its code default still follows opencode_agent (fix(opencode): share runtime pin and observability patch #4288).
    • benchmarks/deepswe/opencode.yaml: an offline sandbox with an operator-staged 1.17.11 binary.
    • Both partner_if_swe_agent blocks: the benchmark's score contract names 1.17.11.
    • environments/harbor/agentic_vbench_train/harbor_train.yaml: 1.19.6 renames the compaction summary sections that vllm_model's summary check expects.
  • OpenCode 2 background compaction. The adapter writes compaction.background: false. 2.3.1 turned background summaries on by default; they run in extra model calls and are held by a process that each Gym run ends. 2.2.7 ignores the key.
  • Version lists. The request-sampling releases (1.17.11 and 1.19.6, which define the same seven built-in agents) are separate from the releases whose error reports were checked (1.17.11, 1.19.6, 2.2.7, 2.3.2).
  • The installer's version-mismatch error names the requested and found versions.
  • README:
    • what changes for configs that relied on the 1.17.11 default;
    • the 1.19.6 behavior changes a recipe may notice;
    • the OpenCode 2.3.x differences (background subagents, background compaction, Code Mode tool names).
    • The Fern row uses the other harness rows' token-capture wording.
  • New tests:
    • the digest table;
    • per-release installer arguments and request sampling;
    • the untested-release warning;
    • the compaction key.

Review fixes (November 24): local runs that exit nonzero

With 1.19.6 capping model-call retries at five, an endpoint outage longer than about a minute ends a local OpenCode run with exit 1. The local path only logged the exit, so opencode_math and opencode_reasoning_gym scored the outage as the model's 0. A local run is now classified the way a sandbox session classifies its run, and the legacy relay verifies only what the agent outcome policy grades.

flowchart LR
  A["local OpenCode run<br/>ends on its own"] --> B{"last assistant<br/>message"}
  B -- "APIError" --> C["failed<br/>HTTP status + ng_agent_outcome"]
  B -- "ContextOverflowError" --> D["incomplete"]
  B -- "none, exit != 0" --> E["failed<br/>outcome unknown"]
  B -- "none, exit 0" --> F["completed"]
  C --> G{"legacy relay:<br/>outcome policy"}
  E --> G
  G -- "verify (400, 413, 422)" --> H["/verify"]
  G -- "retry or fail (5xx, transport, unknown)" --> I["HTTP 502<br/>no reward"]
  D --> H
  F --> H
  classDef new fill:#fff3b0,stroke:#b59f00,color:#000
  class B,G new
Loading

A timeout keeps its existing handling.

Compatibility

  • A config without opencode_version now runs 1.19.6. Its scores are not comparable with earlier runs. These presets move:
    • SWE-bench Verified, Multilingual, Multimodal and Pro (opencode.yaml);
    • Terminal-Bench 2.1 (terminal_bench_2_1/opencode);
    • Agentic-VBench evaluation;
    • the SWE training resources servers' opencode_agent configs;
    • environments/opencode_math and environments/opencode_reasoning_gym.
  • A config that supplies OpenCode or files built for one release must set opencode_version to that release. This covers sandbox_executable_path, an image runtime, and sandbox_plugin_dependencies_path. Setup refuses an executable that reports another version.
  • A local call fails when the host's opencode on PATH reports another version. Upgrade it or pin the version it has.
  • Release downloads with pinned digests need sha256sum in the image.
  • 1.19.6 behavior changes:
    • it retries a failed model call at most 5 times, where 1.17.11 retried until the activation timeout;
    • it drops its built-in temperature and top_p for Qwen model IDs, which changes sampling in the two Qwen-based environments above unless the model server sets it;
    • compaction keeps up to 15k recent tokens with different summary sections;
    • it replaces the oldest images once a request carries more than 25 MiB of them;
    • provider calls with no headers or stream data for 300 s fail. Gym's model server sends keepalives.
  • OpenCode 2.3.x behavior changes:
    • subagents always run in the background, and their reports arrive as messages; opencode run still waits for them;
    • background compaction is off, as on 2.2.7.

Runtime and trajectory evidence

Final head, real model, stock verifier. Terminal-Bench 2.1 regex-log ran through the shipped terminal_bench_2_1/opencode preset (gym eval run --sandbox docker --model-type openai_model --only-tasks regex-log --num-repeats 1, model-call capture on). The Harbor environment server lent the task image to the agent session and graded it with the task's own tests after close. The model was hosted nvidia/nemotron-3.5-super-vl-120b-a12b.

Run OpenCode in the sandbox Model calls / joined turns Tool calls with results Reward Rollout quality
default 1.19.6 5 / 5 4 / 4 1 healthy
opencode_version: "2.3.2" 2.3.2 9 / 9 9 / 9 0 healthy
opencode_version: "2.3.2", repeat 2.3.2 12 / 12 11 / 11 1 healthy
opencode_version: "1.17.11" (main's default) 1.17.11 5 / 5 4 / 4 1 healthy
opencode_version: "2.2.7" (main's v2 pin) 2.2.7 12 / 12 11 / 11 0 healthy
  • Both rows scoring 0 are the model's answers, which the stock tests rejected. The first 2.3.2 regex matched whole lines, and the 2.2.7 regex did not compile.
  • Every run reported zero faulted model responses.
  • Captured prompt and completion tokens equaled the reported usage.
  • Each task container was gone after close.
  • The 1.17.11 run downloaded its release through the newly pinned digest.
  • The pre-fix head had already passed the same task on 1.19.6 and on 2.3.2 (27 calls).
  • Bare alpine:3.20 lacks libstdc++, which all three musl builds need, the same as 1.17.11. With libstdc++ and libgcc added, the x64-baseline-musl builds of 1.17.11, 1.19.6 and 2.3.2 passed their digests and printed their versions.

November 18 paired tool and training checks (signed commit ce0e9f8673). Each row used a fresh Docker sandbox, the Gym agent-session route and its rollout-scoped Responses route, and session close. The settings were hosted nvidia/nemotron-3.5-super-vl-120b-a12b, temperature 0, top-p 1, thinking off, and a 4,096-token per-call limit. Only the input file contained the three operands. An independent host-side verifier read the answer file before close.

Executable version inside the sandbox Successful model calls / matched turns Prompt / completion tokens Answer file / reward
1.17.11 3 / 3 10,554 / 74 480 / 1
1.19.6 3 / 3 10,554 / 74 480 / 1
opencode v2.2.7 3 / 3 5,118 / 72 480 / 1
opencode v2.3.2 3 / 3 5,085 / 72 480 / 1
  • In each saved trajectory, read returned 137, 284, and 59 from /app/parts.txt.
  • write created /app/answer.txt with 480, and the final model reply was 480.
  • V1 used filePath; v2 used path.
  • Each tool result matched its call ID and was present in the next model request.
  • Every assistant-message label matched a close-trajectory turn, and total usage matched the captured model calls.
  • All four containers were removed after close.

A separate GPU run on each updated pin used Qwen/Qwen2.5-0.5B-Instruct with Gym's training-token route. Both replied 2. Every element in the Gym token ledger equaled the sampler's original arrays (v1: 3,146 prompt IDs, 2 generated IDs, 2 log probabilities; v2: 1,344 / 2 / 2).

Terminal-Bench 2.1 smoke A/B (November 20). This is in place of the full 89×8 evaluation. Each version ran 12 tasks once through terminal_bench_2_1/opencode at 81f0a9efa3. The tasks were picked for small images: regex-log, adaptive-rejection-sampler, merge-diff-arc-agi-task, sqlite-with-gcov, count-dataset-tokens, log-summary-date-ranges, openssl-selfsigned-cert, sqlite-db-truncate, gcode-to-text, kv-store-grpc, sparql-university and cancel-async-tasks. The runs used the same hosted model and Docker sandboxes, at concurrency 6; 2.3.2 ran at 3 because the workstation disk was low.

OpenCode Solved / graded Dropped rows Rollout quality Faulted responses
1.17.11 (main's default) 6 / 12 0 12 healthy 0
1.19.6 (this PR's default) 8 / 12 0 12 healthy 0
2.2.7 (main's v2 pin) 9 / 10 2 10 healthy 0
2.3.2 (this PR's v2 pin) 9 / 11 1 11 healthy 0
  • 1.19.6 solved two more tasks than 1.17.11 (adaptive-rejection-sampler and kv-store-grpc) and solved nothing fewer.
  • 2.3.2 solved count-dataset-tokens and failed adaptive-rejection-sampler, compared with 2.2.7.
  • With one repeat per task, these are smoke signals, not accuracy estimates.
  • Captured tokens equaled reported usage in every run.
  • On both OpenCode 2 releases, a task that reached its 900 s agent timeout was dropped instead of scored:
    • OpenCode 2 ends the step with MessageAbortedError, which reaches the Environment Server as a 502 (environment_server_failed).
    • The affected rows are gcode-to-text and cancel-async-tasks on 2.2.7, and gcode-to-text on 2.3.2.
    • Main's 2.2.7 pin behaves the same way, so this is not a change from this PR. A separate fix is needed.

These checks do not cover:

  • benchmark accuracy (the full Terminal-Bench 2.1 89×8 before/after evaluation);
  • optimizer execution;
  • multi-turn training lineage;
  • arm64 execution;
  • a 2.3.x run that uses subagents or reaches compaction.

Validation

All checks ran on the final head on a Linux workstation.

  • pre-commit run --all-files passed with no file changes.
  • cd fern && npm run check -- --warnings: 0 errors and 1 warning. The redirects check was skipped without authentication.
  • 2,393 passed, 21 skipped, with the real 1.19.6 binary in GYM_TEST_OPENCODE_BINARY:
    pytest -n 8 responses_api_agents/opencode_agent/tests responses_api_agents/opencode_sandboxed_agent/tests tests/unit_tests/models/test_token_capture_harness_notes.py tests/unit_tests/test_session_contract_repo.py tests/unit_tests/benchmarks tests/unit_tests/tooling/test_agent_environment_repository_configs.py.
    • The skips are dependencies or tools the workstation environment lacks (Ray, COMET, OpenCV, ffmpeg, Bash 5.1, an Agentic-VBench checkout).
    • test_babyvision_opencode_prepare.py needed Pillow and passed in the next run.
  • 473 passed, 2 failed, 1 skipped (--import-mode=importlib):
    pytest tests/unit_tests/benchmarks/test_babyvision_opencode_prepare.py resources_servers/agentic_if/tests/test_config.py resources_servers/agentic_if/tests/task_variants/test_builtin_schema_snapshot.py benchmarks/agentic_if/tests/test_benchmark_config.py resources_servers/equivalence_llm_judge/tests/test_hle_diamond.py responses_api_agents/pi_agent/tests/test_offline_science_presets.py resources_servers/opencode_search/tests resources_servers/visual_coding_opencode/tests/test_opencode_session.py environments/pdf_analyst_qa/tests/test_dataset.py benchmarks/terminal_bench_2_1/tests resources_servers/mm_coding_training/tests/test_catalog.py resources_servers/mm_coding_training/tests/test_review_regressions.py resources_servers/deepswe_external1/tests/test_config.py resources_servers/swebench_pro_v2/tests/test_prepare.py responses_api_agents/vibench_agent/tests.
    • The two failures are test_nooa_terminal_bench_2_1.py's NOOA and Pi num_workers assertions. They fail the same way on main at 240fedc348.
  • Upstream checks at tags v1.17.11, v1.19.6, v2.2.7 and v2.3.2:
    • All 12 pinned digests equal the GitHub release asset digests.
    • Each archive's first member is opencode, for the right architecture and libc.
    • max-steps.ts is the same blob at all four tags.
    • The seven built-in agents and the error types are unchanged.

🤖 Generated with Claude Code

@yaoyu-33 yaoyu-33 added feature New capabilities, enhancements, or enablement work area:agent Agent harnesses and Responses API agent behavior labels Nov 19, 2026
@copy-pr-bot

copy-pr-bot Bot commented Nov 19, 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 the risk:mid Autobot PR risk: mid label Nov 19, 2026
yaoyu-33 and others added 2 commits November 19, 2026 19:54
…nges

Review fixes for the OpenCode 1.19.6 / 2.3.2 upgrade:

- Pin opencode_version 1.17.11 where results or shipped assets are tied to it:
  the deprecated opencode_sandboxed_agent base config (its code default still
  follows opencode_agent's), DeepSWE (offline sandbox, operator-staged 1.17.11
  binary), Partner IF's SWE agent (its score contract names 1.17.11), the
  Agentic-VBench training entry (1.19.6 renames the compaction summary sections
  vllm_model checks) and the opencode_search example.
- OpenCode 2: write compaction.background false. 2.3.1 turned background
  summaries on by default; each Gym run is its own process, so a held summary
  is lost. 2.2.7 ignores the key.
- Pin the 1.17.11 release digests, so explicit 1.17.11 downloads are checked.
- Separate the request-sampling releases from the releases whose error reports
  were checked, and say what each list means.
- Name the requested and found versions in the installer's mismatch error.
- README: what changes with the new default (migration of self-supplied
  binaries and bundles, host CLI, sha256sum, 1.19.6 retry cap, Qwen sampling
  defaults, compaction, 25 MiB image bound, 300 s provider timeouts) and the
  OpenCode 2.3.x differences (background subagents and compaction).
- Fern: match the other harness rows' token-capture wording.
- Tests for the release digests, per-release install arguments, sampling gate,
  untested-release warning and the compaction key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33 yaoyu-33 changed the title feat(opencode): upgrade native v1 and v2 releases feat(opencode): upgrade opencode_agent to OpenCode 1.19.6 and 2.3.2 Nov 20, 2026
@yaoyu-33

Copy link
Copy Markdown
Contributor Author

/ok to test 81f0a9e

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

@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

No qualifying issues found. I reviewed every changed file and traced the affected installation and session paths through their callers and tests. The explicit 1.17.11 pins keep fixed-runtime recipes on their qualified release, and both OpenCode 2 launch paths disable background compaction.

This was a static review. I did not execute tests or independently verify upstream release assets. The PR reports representative real-model runs, with OpenCode 2.3.x subagents and compaction explicitly outside that evidence.

Note: formal approval is not available for this request, so this review is posted as a comment only.

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

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Nov 20, 2026
…e-v1-v2

Resolve conflicts with main's checkpoint/resume (#5268) and task-container (#5458) work:
- app.py: keep main's _reported_model_error signature (reprompted) with the
  _CLASSIFIED_OPENCODE_VERSIONS docstring; take main's _install_session_files call and
  pass the release digests for every pinned version there, as the PR did inline.
- README.md: OpenCode 2 prints v2.3.2, plus main's task-container sentence.

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 a102593

@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 23, 2026 20:32
@yaoyu-33
yaoyu-33 requested a review from zyzhou5 November 23, 2026 20:39
@cmunley1

Copy link
Copy Markdown
Contributor

One issue from a local review (with a repro test):

environments/opencode_math/config.yaml and environments/opencode_reasoning_gym/config.yaml drop their opencode_version: 1.17.11 pin here, so both now run 1.19.6. 1.19.6 stops after 5 retries (RETRY_MAX_RETRIES in packages/opencode/src/session/retry.ts, about 60 to 75 s) and adds 300 s header and SSE-idle timeouts. 1.17.11 kept retrying until the episode timeout.

Both envs run the local path. There a nonzero OpenCode exit is only logged (app.py:1153), and run_status = "failed" is written to the observations only (app.py:1196). The response that reaches /verify is an ordinary completed one with whatever output was parsed. So a policy endpoint outage longer than about a minute (a vLLM restart, 429s under load) is scored as the model's 0 instead of an infra failure.

Suggestion: on the local path, treat a nonzero exit as a failed run, the way the sandbox path already does (status failed, error set, failure_report attached), so the environment can mask the sample instead of scoring it. That covers every unpinned config, not just these two.

Repro: a stand-in opencode that exits 1 with APIError: 503 Service Unavailable (retries exhausted), run through _create_episode with each env's config, reaches /verify with status=None, no error and an empty completed assistant message.

A local OpenCode run that exited nonzero was only logged, so its response
reached /verify as an ordinary completed one. With 1.19.6 capping model-call
retries at five, an endpoint outage longer than about a minute was scored as
the model's 0 in the local recipes (opencode_math, opencode_reasoning_gym).

Classify the exit the way a sandbox session does: a provider failure OpenCode
recorded fails the response with its HTTP status and outcome, any other
nonzero exit fails it with an unknown cause, and a context overflow leaves it
incomplete. The legacy relay verifies only what the agent outcome policy
grades; anything else fails the rollout with HTTP 502 and no reward.

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 0f84782

Copy link
Copy Markdown
Contributor Author

Thanks, fixed in 0f84782.

A local run is now classified the way a sandbox session classifies its run:

How OpenCode ended Response
APIError on the last assistant message (exit 1) failed, HTTP <status>: <message>, ng_agent_outcome from the same classify_outcome
any other nonzero exit failed, OpenCode exited with code N plus stderr, outcome unknown
ContextOverflowError incomplete, graded as before

legacy_app.py now calls /verify only when the agent outcome policy grades the response. An endpoint outage (5xx, 429, transport) or an unexplained exit fails the rollout with HTTP 502 and no reward, so it is never a 0. A rejected request (400, 413, 422) and a context overflow are still graded. The root invocation's status and error_type match. This applies to every unpinned local config, not just the two recipes.

Your repro is now test_legacy_recipe_scores_only_runs_the_outcome_policy_grades. It runs a stand-in opencode through the opencode_math and opencode_reasoning_gym configs. On a102593, the outage and unexplained-exit cases reached /verify with status=None and were scored. On the fix they do not reach /verify.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added risk:high Autobot PR risk: high and removed risk:mid Autobot PR risk: mid labels Nov 24, 2026
cmunley1
cmunley1 previously approved these changes Nov 24, 2026

@cmunley1 cmunley1 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.

LGTM. Rechecked 0f84782: a local OpenCode run now classifies its exit the same way a sandbox session does. The remaining failures are the non-blocking conformance and compliance jobs.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the ready-to-merge PR is approved, current, and waiting for final CI or merge label Nov 24, 2026
Signed-off-by: svcnemo-autobot <[email protected]>
@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

/ok to test 9f8c76e

@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 24, 2026
@yaoyu-33
yaoyu-33 enabled auto-merge November 25, 2026 01:18
@yaoyu-33
yaoyu-33 disabled auto-merge November 25, 2026 01:18
@yaoyu-33
yaoyu-33 merged commit b905fad into main Nov 25, 2026
80 of 85 checks passed
@yaoyu-33
yaoyu-33 deleted the codex/upgrade-opencode-v1-v2 branch November 25, 2026 01:19
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 feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer ready-to-merge PR is approved, current, and waiting for final CI or merge risk:high Autobot PR risk: high sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants