You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: add OpenCode Go tier policy and weekly models.dev refresh - #3
Add opencode_go tier model policy to config/api-tier-models.json and wire opencode_go into POLICY_PROVIDER_KEY in src/api.mjs, allowing Workers to use "tier_models": "policy" and "models": {"opencode-go": "policy"}.
Add zero-dependency scripts/refresh-opencode-models.mjs (--check / --write) to resolve the latest stable GLM, Qwen, Kimi, and DeepSeek flagship & flash models from https://models.dev/api.json.
Add weekly GitHub Actions workflow .github/workflows/refresh-opencode-models.yml (SHA-pinned) to automatically open/update a PR when the OpenCode Go catalog advances.
Update wrangler.example.jsonc to reflect cloudflare_workflow and tier_models: "policy".
Verification
node scripts/refresh-opencode-models.mjs --check (0 drift against live models.dev/api.json)
The core wiring is sound: actions are SHA-pinned, no secrets are hardcoded (only key_env names), fetch failures fail closed, and the new provider key maps correctly to tier_models.opencode_go. However, the delivered automation is self-defeating in two ways: (1) the new test hardcodes the current catalog IDs, so any real models.dev advance — the exact event this PR automates — fails npm test, and since the PR-creation step carries an implicit success() gate, the refresh PR is never opened; (2) the workflow never fetches the existing bot branch, so git push --force-with-lease has no remote-tracking state on week 2+ and the push is rejected as stale/non-fast-forward, breaking the weekly update path after the first run. Lower-severity gaps: externally sourced model IDs are written into the policy without validating against the runtime modelId charset, the CLI write/check paths and the tool_call===false exclusion are untested, and the cloudflare_workflow example mixes API-provider-style fields whose consumption should be verified.
[MEDIUM]test/refresh-opencode-models.mjs: The second test hardcodes current catalog literals ('qwen4-max', 'glm-5.3', 'kimi-k3.1-pro', 'deepseek-v4-pro', 'glm-5.3-flash') that must match config/api-tier-models.json. When the weekly refresh actually changes models — the exact scenario this PR automates — the workflow rewrites the config on disk, npm test then fails against the new IDs, and because the 'Open or update pull request' step's if: steps.diff.outputs.changed == 'true' has an implicit success() gate, the PR step is skipped. The automation can therefore only succeed when nothing changed. Derive expected models from the config/selection output (or assert structural invariants like non-empty tiers and config/policy consistency) instead of frozen literals.
[MEDIUM].github/workflows/refresh-opencode-models.yml: The branch update path breaks after the first run. actions/checkout (default fetch-depth, default branch only) leaves no remote-tracking ref for chore/refresh-opencode-go-models, so on week 2+ git push --force-with-lease origin "$BRANCH" resolves the lease to a null expected value against an existing remote branch and is rejected as stale (a plain push would also be non-fast-forward). The scheduled job will fail and never update the open PR. Fetch the existing branch first (e.g. git fetch origin "$BRANCH" and base the lease on it), use an explicit --force-with-lease=<ref>:<expect>, or use plain --force on this bot-only branch.
[LOW]scripts/refresh-opencode-models.mjs: Model IDs sourced from the external models.dev catalog are written into config/api-tier-models.json without validating against the runtime admission regex in src/api.mjs (/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/). A malformed or unexpectedly named ID from the third-party catalog would be committed by the automation and then silently rejected or misrouted at runtime. Validate selected IDs against the same charset before writing the policy.
[LOW]scripts/refresh-opencode-models.mjs: Test coverage only exercises the pure selection function. The CLI behavior is untested: the --write file-update/drift-detection path (including the JSON.stringify key-order-sensitive comparison), the --check exit code on drift, and the isStableModel tool_call === false exclusion all lack tests, so a regression in the write/check logic would only surface as a broken scheduled workflow.
[LOW]wrangler.example.jsonc: The cloudflare_workflow agent provider now carries API-provider-style fields (base_url, key_env, fallback_models) and flips capabilities.image_input to true. Confirm the workflow-dispatch path actually consumes these fields and that the selected GLM/Qwen/Kimi/DeepSeek models accept image input; otherwise the example misleads users into configuring a key/base_url that is ignored and enabling a capability the models may not support.
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
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
opencode_gotier model policy toconfig/api-tier-models.jsonand wireopencode_gointoPOLICY_PROVIDER_KEYinsrc/api.mjs, allowing Workers to use"tier_models": "policy"and"models": {"opencode-go": "policy"}.scripts/refresh-opencode-models.mjs(--check/--write) to resolve the latest stable GLM, Qwen, Kimi, and DeepSeek flagship & flash models fromhttps://models.dev/api.json..github/workflows/refresh-opencode-models.yml(SHA-pinned) to automatically open/update a PR when the OpenCode Go catalog advances.wrangler.example.jsoncto reflectcloudflare_workflowandtier_models: "policy".Verification
node scripts/refresh-opencode-models.mjs --check(0 drift against livemodels.dev/api.json)npm run buildnode --test test/refresh-opencode-models.mjs(2/2 pass)node --test test/routing.mjs(38/38 pass)AI assistance
Implemented and verified with Antigravity.