feat(harness): pre-fetch models.dev catalog in opencode provisioner - #1308
Conversation
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
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request adds a pre-fetching mechanism for the latest models catalog from models.opencode.ai during the provisioning step of the opencode harness, saving it to a local cache to ensure fresh model data. The review feedback suggests validating that the fetched catalog is indeed valid JSON before caching it, preventing potential crashes or parsing failures in opencode if an invalid response or error page is received.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Summary
Adds a best-effort pre-fetch step to the opencode provisioner that downloads the latest models catalog from models.opencode.ai during provision and writes it to opencode cache location (~/.cache/opencode/models.json).
Motivation
opencode bakes a models.dev snapshot at build time. When new models are released after the image is built, opencode model validation rejects them. Pre-fetching the catalog during provision ensures fresh model data is available before opencode starts.
Changes
Single file: harnesses/opencode/provision.py
Related: ptone#1283