Skip to content

opencode_env: don't retry the install when version resolution fails - #1074

Open
jayzuccarelli wants to merge 3 commits into
huggingface:mainfrom
jayzuccarelli:opencode-install-fatal-version-failure
Open

opencode_env: don't retry the install when version resolution fails#1074
jayzuccarelli wants to merge 3 commits into
huggingface:mainfrom
jayzuccarelli:opencode-install-fatal-version-failure

Conversation

@jayzuccarelli

@jayzuccarelli jayzuccarelli commented Aug 10, 2026

Copy link
Copy Markdown

Summary

_bootstrap_sandbox installs opencode per sandbox, and with the default opencode_version="latest" the upstream installer resolves the version through api.github.com (60 req/hr unauthenticated). When that lookup fails it prints Failed to fetch version information on stdout and exits 1 with an empty stderr — exactly the signature _exec_with_retry classifies as transient. So every rate-limited bootstrap burns 3 API calls instead of 1, and the final RuntimeError buries the actual cause in stdout_tail.

This PR takes the retry-amplification half of #1072:

  • _exec_with_retry gains a fatal_markers escape hatch: a failure whose stdout matches a marker is deterministic and not retried, even with empty stderr.
  • The install call site marks the installer's version-resolution failure as fatal and re-raises with an actionable message: pin opencode_version to a release tag (the pinned branch of the installer resolves via a plain curl -sI to github.com, no API quota involved).

The larger direction — prebaking the binary into the template or moving the default off "latest" — is a design call better made on the issue.

Test plan

Red-green: the three new tests in tests/envs/test_opencode_factory_lifecycle.py fail on main (install retries all 3 attempts, no actionable message) and pass with the fix. Full suite: PYTHONPATH=src:envs pytest tests/ → 1532 passed, 133 skipped; the one failure (test_push_count_deploys_multiple_spaces) reproduces identically on clean main.


Note

Low Risk
Sandbox bootstrap and install-command construction only; behavior change is fewer retries and clearer errors on deterministic install failures.

Overview
Fixes sandbox bootstrap wasting three GitHub API calls when the OpenCode installer fails to resolve latest (rate limit): that failure prints on stdout with empty stderr, which _exec_with_retry treated as transient.

_exec_with_retry now accepts optional fatal_markers; if failed stdout contains a marker, it stops retrying immediately (silent SIGKILL-style failures still retry).

Install path passes fatal_markers for the installer’s version-fetch error and maps it to a clear RuntimeError suggesting users pin opencode_version to avoid the api.github.com lookup.

build_install_cmd pins versions via curl … | bash -s -- --version <tag> instead of a OPENCODE_VERSION prefix on curl, so the version actually reaches the bash installer.

Reviewed by Cursor Bugbot for commit 3b122d7. Bugbot is set up for automated code reviews on this repo. Configure here.

The upstream installer resolves opencode_version='latest' through
api.github.com (60 req/hr unauthenticated) and reports a failed lookup on
stdout with an empty stderr — the exact signature _exec_with_retry treats
as transient. Each sandbox bootstrap then burns 3 API calls instead of 1,
and the raised error hides the cause in stdout_tail.

Teach _exec_with_retry a fatal_markers escape hatch, mark the installer's
version-resolution failure as fatal at the install call site, and raise an
actionable error pointing at pinning opencode_version (the pinned branch
of the installer never touches the API).

Addresses the retry-amplification half of huggingface#1072; avoiding the API lookup
entirely (prebaked template / pinned default) is left as a design call on
the issue.

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d26c957. Configure here.

Comment thread envs/opencode_env/harness.py
OPENCODE_VERSION= prefixed onto curl never reaches the bash side of the
curl | bash pipeline, and the upstream installer reads VERSION / --version
anyway — so pinning silently tracked latest. Pass --version via
bash -s -- instead, per the installer's own usage text.
@jayzuccarelli

Copy link
Copy Markdown
Author

@sergiopaniego you've been shipping the recent opencode_env changes, so pinging you here rather than the whole team. This one makes _bootstrap_sandbox stop retrying the install when the upstream installer's version lookup fails (the retry never helps, the GitHub API rate limit is per hour), and fixes the OPENCODE_VERSION pin so it actually reaches the installer's bash side. The cursor bot's point about the pin is addressed in the second commit. Small diff, CI green. Anything you'd like changed?

@cursor
cursor Bot requested a review from burtenshaw September 9, 2026 13:04

@cursor cursor Bot 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.

Reviewed exact head 3b122d74dbc232e5ac456857e7b16164e497bbcd against current main f8433a56f2fde5a6f20765b491b8365fc123f7fa. The fatal version-lookup classification and bash -s -- --version propagation are correct; the prior Bugbot concern is resolved, all 9 focused tests pass locally, the changed scope is lint-clean, and the merge-tree is conflict-free. No Tier-1 or alignment defect remains.

This is not merge-ready yet because the standard workflows never executed (action_required at this exact head), and the branch is behind current main. A maintainer must approve the external-branch workflows, refresh the branch, and require all exact-head checks to pass. burtenshaw is already requested; no code change is otherwise required.

View PR

Open in Web View Automation 

Sent by Cursor Automation: Release

@jayzuccarelli

Copy link
Copy Markdown
Author

@burtenshaw you're the requested reviewer here, so pinging you directly. Small change to _bootstrap_sandbox: stop retrying the install when the upstream installer's version lookup fails, and pass the pin through --version so it actually applies. Bugbot has reviewed the current head clean; it just needs the workflows approved.

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