Skip to content

fix(agents): OpenCode installs on a bare target, and defaults to claude-sonnet-5-5 - #917

Merged
earakely-scale merged 3 commits into
mainfrom
edgararakelyan/opencode-relay-cas
Nov 25, 2026
Merged

earakely-scale merged 3 commits into
mainfrom
edgararakelyan/opencode-relay-cas

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

opencode-cli has failed its promotion gate on every release since 0.9.1624: 0.9.1624, 0.9.1636, 0.9.1639 and 0.9.1642. Two checks failed, install and the task run, and each time the gate rolled back to the image from before #865. This PR fixes both.

1. install: an installed OpenCode had no CA certificates

  • Since feat(agents): OpenCode reports each turn's token usage, counted at a model relay of its own #865, every OpenCode model call goes through the turn's model relay, model_relay.py. The relay runs in the agent's own Python, an aiohttp ClientSession, so it verifies TLS against the system's CA store. Before feat(agents): OpenCode reports each turn's token usage, counted at a model relay of its own #865 the OpenCode CLI made those calls itself and used its own bundled CAs.
  • install/v1 installs the agent into a bare ubuntu:24.04 container, which has no ca-certificates.
  • On a remote sandbox (modal_vm, which the gate uses), install_agent passes no trust lines. So every call the relay forwards fails TLS and comes back to the CLI as a 502 (model relay: ClientConnectorCertificateError). OpenCode retries until the turn times out and never answers.
  • On a local sandbox, install_agent passes LOCAL_TRUST_ENV, whose SSL_CERT_FILE names a bundle. That's why local runs pass.

Fix:

  • install.sh ports Codex's fallback. When the target has no system CA bundle, and the trust lines don't name one, the agent's environment gets SSL_CERT_FILE pointing at certifi's bundle from the agent's own Python. Both the relay (Python's default TLS context) and the CLI (Bun) honour SSL_CERT_FILE.
  • The install now fails if certifi's bundle is missing.
  • certifi is now listed in the agent's requirements. It was already installed as a dependency of httpx.
  • Nothing changes on a target that has its own CAs or whose trust lines name a bundle.
  • The new unit test runs install.sh's actual decision against faked targets.

2. The task run: OpenCode's default model gets the task wrong

Fix: OpenCode's default model is now anthropic/claude-sonnet-5-5, the model the hub already sets for pi and OpenHands. On the same task it lists the inbox with an empty query and gets all three emails, as Claude Code does. It also costs less per token: $2/$10 per million input/output tokens, against $3/$15.

Testing

All runs were on Linux EC2 boxes in the agent-environments-admin account. Real turns used LiteLLM and cost about $20 in total. "Fixed image" means this branch; the comparison is main.

  • The gate's task run, with its own verifier (an agent judge plus the trajectory, no judge model set, the gate's prompt and criteria):

    • main's image and the image with only fix 1 both reply "1 email" and score 0.0, on every run.
    • The fixed image replies "3 emails" and scores 1.0 in 3 of 3 runs.
    • Claude Code under the same verifier also scores 1.0.
  • Bare ubuntu:24.04 with no trust lines (install.sh container, then "Respond with OK." over A2A, as install/v1 does on a remote sandbox):

    • main: every relayed call returned a 502 and the agent never answered.
    • Fixed image: SSL_CERT_FILE points at certifi, and the agent replies "OK".
  • Other install targets: on python:3.12-slim (which has its own CAs), on a bare ubuntu whose trust lines name a bundle, and as a host install on the box, main and the fixed tree write the same SSL_CERT_FILE (or none), and the agent answers.

  • Full A2A validator (agent-env a2a-agent validate, local Docker): every extension result matches main, including install/v1 and clock/v1 (synced, follows writes).

  • Clock e2e (tst/integration/task_step/test_agent_env_clock_local.py -k opencode): passes on both images. tst/integration/agent/opencode_env_date_test.py passes 2 of 2.

  • Clock chaos with real model turns. Each round deploys the mail env and the agent, arms the clock with require_agent_clock, and runs 13 scenarios:

    • a frozen date that both the shell and the CLI's date line show;
    • forward and backward jumps between turns of one session, with history still in order (FD-6473);
    • a clock before 1970;
    • a 3600x rate;
    • a jump while a turn runs;
    • the clock follower killed with kill -9, restarted by supervisord, with writes waiting for it again;
    • the egress proxy killed and restarted, followed by an MCP tool turn on the env's clock;
    • teardown retiring the follower;
    • the A2A server killed, which stops the container ([FD-5916] fix(agents): a clocked agent's container exits when its server dies #862).

    Every date turn has to echo a fresh nonce, so an answer copied from history doesn't pass.

    • Fixed image: 13/13 in each of 7 rounds, 4 of them run at the same time.
    • The image with only fix 1: 13/13 in 4 rounds.
    • main: 13/13 in 3 rounds.
    • One round of the fix-1-only image failed the 3600x scenario once. OpenCode exited before its main loop, which suggests the relay refused the call while reading the env's date under load. That image's runtime code equals main's, and it didn't recur in 22 other rounds, including 6 run at the same time.
  • Unit tests: tst/unit/agents/opencode passes.

Not in this PR

  • Letta Code also takes the model relay, and its install.sh has no CA fallback either. Hermes also still defaults to claude-sonnet-4-6. Neither is in the promotion gate.
  • Local image builds can reuse a stale COPY layer. The staged build context sets every file's mtime to 1970. When a file is edited without changing its size (as with 4-6 to 5-5 here), BuildKit treats it as unchanged and keeps the cached layer. CI and release builds start without a local cache, so they're unaffected.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no new blocking issues were found.

Summary

OpenCode installs now use certifi’s CA bundle when the target has no system bundle and no explicit SSL_CERT_FILE.

  • OpenCode installs use certifi when the target has no CA bundle.
  • OpenCode uses Claude Sonnet 5.5 as its default model.

Reviews (3) · Last reviewed commit: "fix(agents): OpenCode's default model is..." · Reviewed by Greptile

…ith none

Since OpenCode's model calls go through the turn's model relay (#865), the
agent's own Python makes them, and it reads the system's CA certificates. A
bare target has none: on a remote sandbox, where install_agent passes no trust
lines, every call the relay forwarded failed TLS and came back 502, so the
installed agent never answered and install/v1 failed (the promotion gate has
rolled back opencode-cli on every release since 0.9.1624). Like Codex, such a
target's agent now trusts certifi's bundle, from its own Python, unless the
trust lines name one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
earakely-scale and others added 2 commits November 24, 2026 14:35
The test read install.sh's text, so a broken check would still have passed.
It now runs the decision itself, its target's /etc a temp folder: no bundle,
each system bundle, an empty one, and trust lines naming a bundle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OpenCode still defaulted to claude-sonnet-4-6. On the promotion gate's task run
("list every email" over a search-only tool) that model searches for "the" and
reports one email of the inbox's three; since judges default to
claude-sonnet-5-5 (#878) the gate grades that 0. With claude-sonnet-5-5 OpenCode
lists the inbox with an empty query, as Claude Code does, at a lower price per
token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale earakely-scale changed the title fix(agents): an installed OpenCode trusts certifi's CAs on a target with none fix(agents): OpenCode installs on a bare target, and defaults to claude-sonnet-5-5 Nov 25, 2026
@earakely-scale
earakely-scale merged commit 466ef65 into main Nov 25, 2026
36 checks passed
@earakely-scale
earakely-scale deleted the edgararakelyan/opencode-relay-cas branch November 25, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant