feat(harness): pre-fetch models.dev catalog in opencode provisioner - #1283
Open
ptone wants to merge 4 commits into
Open
feat(harness): pre-fetch models.dev catalog in opencode provisioner#1283ptone wants to merge 4 commits into
ptone wants to merge 4 commits into
Conversation
added 3 commits
August 27, 2026 00:17
opencode bakes a models.dev snapshot at build time; when new models are released after the image is built, its validation rejects them. Add a best-effort pre-fetch step that downloads the latest catalog from models.opencode.ai during provision and writes it to the opencode cache location (~/.cache/opencode/models.json). This ensures fresh model data is available when opencode starts, without failing provision if the fetch errors out.
R1: Broaden except clause to catch Exception for best-effort code O1: Add 10MB size cap to resp.read() for defense in depth O2: Use temp file + os.replace for atomic write
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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.
Summary
harnesses/opencode/provision.pythat downloads the latest models catalog fromhttps://models.opencode.ai/api.jsonduring provision~/.cache/opencode/models.json(opencode's primary cache location) so fresh model data is available when opencode startsurllib.requestwith a 10-second timeout; logs success/failure viactx.info()but never fails provision on fetch errorsMotivation
opencode bakes a models.dev snapshot at build time. When new models are released after the image is built, opencode's model validation rejects them. While opencode does a background re-fetch, the v1 Provider system doesn't refresh from it at startup. Pre-fetching the catalog during provision ensures the data is fresh before opencode reads it.
Test plan
python3 -c "import py_compile; py_compile.compile('harnesses/opencode/provision.py', doraise=True)"~/.cache/opencode/models.jsonexists with fresh catalog data