Skip to content

feat: support OpenCode 2.x - #36

Merged
younesbelkada merged 2 commits into
mainfrom
feat/opencode-2
Nov 17, 2026
Merged

younesbelkada merged 2 commits into
mainfrom
feat/opencode-2

Conversation

@younesbelkada

Copy link
Copy Markdown
Collaborator

Adds OpenCode 2.x to the OpenCode guide and its harness test, and fixes the harness / opencode failure on main.

Why main is red. The opencode latest job installs the newest opencode-ai, and 1.19.6 (released 2026-11-17 07:22 UTC) broke its Anthropic provider (UnknownError: Unexpected server error). The pinned 1.19.3 job still passes. 1.x is now in maintenance and prompts users to upgrade to 2.x, which ships as a separate npm package, @opencode/cli, so the latest job could never have tested 2.x anyway.

What 2.x changes for us (checked by running 2.3.0 through safeagents against the scripted model):

  • Config: providers.<id>.settings.baseURL instead of provider.<id>.options.baseURL, package instead of npm (@opencode/ai/providers/openai-compatible), agents.title.model instead of small_model, policies instead of disabled_providers. 1.x configs still load.
  • The shell tool is shell with {command} only; its schema rejects the description 1.x required.
  • 2.x's catalog no longer lists claude-sonnet-4-5 and silently swaps an unknown model for its default (claude-fable-5-2), so the guide uses claude-sonnet-5-5.
  • Sessions run in a background service shared by the user's OpenCode processes. The test uses --standalone for isolation; the guide notes opencode service restart after changing keys.
  • Wire formats are unchanged: Anthropic Messages at /v1/messages, Chat Completions at /v1/chat/completions. The built-in openai provider still uses /v1/responses, so the warning stays.
  • New execute tool (Code Mode) wraps tool calls in code. The guard's checks match argument text, so curl to an unknown host or safeagents stop inside execute is blocked like a shell call.

Changes

  • docs/opencode.md: an OpenCode 2.x section before the 1.x one, plus 2.x notes. docs/README.md marks both as supported.
  • tests/harnesses/test_opencode.py: picks config, shell tool, models and run flags from opencode --version. New check_model asserts OpenCode called the configured model (it fails with OpenCode called {'claude-fable-5-2'} on a stale model name). Includes the earlier --print-logs commit, so a failure shows OpenCode's own server error.
  • .github/workflows/harness-opencode.yml: pull requests test opencode-ai@1.19.3 and @opencode/cli@2.3.0; pushes to main add @opencode/cli@latest. The 1.x latest job is dropped.

Tests: opencode harness 6/6 against 2.3.0 and 6/6 against 1.19.5 locally; full suite 134 passed, 33 skipped.

🤖 Generated with Claude Code

younesbelkada and others added 2 commits November 17, 2026 11:54
opencode run only reports "Unexpected server error. Check server logs for
details.", and the logs went to a temporary home the test then discarded.
Send them to stderr, which the failure message already includes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OpenCode 2 ships as a separate npm package (@opencode/cli) and renames most of
what the guide and the harness test rely on: `providers`/`settings.baseURL`/
`package` instead of `provider`/`options.baseURL`/`npm`, `agents.title.model`
instead of `small_model`, a `shell` tool (only `command`, no `description`)
instead of `bash`, and a background service shared by all OpenCode processes.
Its catalog no longer lists claude-sonnet-4-5, and it silently swaps an unknown
model for its default one.

- docs/opencode.md: an OpenCode 2.x section next to the 1.x one.
- tests/harnesses/test_opencode.py: picks the config, shell tool and models
  from `opencode --version`, runs 2.x with --standalone, and checks that the
  configured model is the one OpenCode called.
- CI: test opencode-ai@1.19.3 and @opencode/cli@2.3.0 on pull requests, plus
  @opencode/cli@latest on main. The 1.x `latest` job goes: 1.x now nags to
  upgrade, and 1.19.6 broke its Anthropic provider.

Checked locally against OpenCode 2.3.0 and 1.19.5: the guard needs no change
(2.x's Anthropic and OpenAI-compatible providers use Messages and Chat
Completions; the built-in openai provider still uses the Responses API).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@younesbelkada
younesbelkada merged commit dcf38e0 into main Nov 17, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant