Skip to content

feat: add OpenCode Go tier policy and weekly models.dev refresh - #3

Merged
Pigbibi merged 1 commit into
mainfrom
feat/opencode-go-model-refresh
Dec 2, 2026
Merged

Pigbibi merged 1 commit into
mainfrom
feat/opencode-go-model-refresh

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 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)
  • npm run build
  • node --test test/refresh-opencode-models.mjs (2/2 pass)
  • node --test test/routing.mjs (38/38 pass)

AI assistance

Implemented and verified with Antigravity.

@Pigbibi
Pigbibi merged commit 0d31263 into main Dec 2, 2026
1 check failed
@Pigbibi
Pigbibi deleted the feat/opencode-go-model-refresh branch December 2, 2026 19:45
@cgl-opencode-reviewer

Copy link
Copy Markdown

AI Code Review (opencode / glm-5.3)

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.

Reviewed commit: fa4566442e · Coverage: complete · Unresolved findings: true

Findings

  • [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.

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