feat(model-capabilities): add models.dev snapshot and runtime capability refresh#2826
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@code-yeongyu this is ready for review. It adds the separate models.dev-backed model capability layer we discussed, keeps the old PR stack untouched, and includes focused verification in the PR body. The only remaining full-suite failure is the pre-existing |
There was a problem hiding this comment.
6 issues found across 29 files
Confidence score: 2/5
- I’m marking this as high risk because there are multiple high-severity, high-confidence compatibility issues (7–8/10) that can cause incorrect capability detection and provider behavior at runtime.
- The most severe issue is in
src/shared/model-capabilities.ts: Opencode SDK v2 structuredcapabilitiesfields (e.g., reasoning/temperature/toolcall) are ignored, which can lead to wrong capability resolution for supported models. src/shared/model-capability-heuristics.tsandsrc/shared/connected-providers-cache.tsinclude concrete regression risks: unsupportedgpt-5"max" handling, overly strictopenai-reasoningmatching, and metadataidoverwrite that can break normalized lookups.- Pay close attention to
src/shared/model-capabilities.ts,src/shared/model-capability-heuristics.ts,src/shared/connected-providers-cache.ts, andsrc/shared/model-capabilities-cache.ts- capability resolution, variant handling, and ID/normalization invariants are at risk.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/shared/model-capability-heuristics.ts">
<violation number="1" location="src/shared/model-capability-heuristics.ts:27">
P2: `openai-reasoning` regex is too strict (`^` anchor) and misses valid prefixed model IDs, preventing reasoning-family capability resolution.</violation>
<violation number="2" location="src/shared/model-capability-heuristics.ts:34">
P1: Custom agent: **Opencode Compatibility**
The `max` variant is not supported for `gpt-5` models in the Opencode SDK. It is Anthropic-specific (used via `adaptiveEfforts` for models like `opus-4.6`). Remove `\"max\"` from the `gpt-5` variants list to ensure Opencode compatibility.</violation>
</file>
<file name="src/shared/model-capabilities.ts">
<violation number="1" location="src/shared/model-capabilities.ts:75">
P2: isRecord treats arrays as records, so normalizeVariantKeys will accept array variants and turn them into numeric string keys ("0", "1"), corrupting runtime variants.</violation>
<violation number="2" location="src/shared/model-capabilities.ts:190">
P1: Custom agent: **Opencode Compatibility**
The capability resolver ignores the Opencode SDK v2's structured `capabilities` object.
In the Opencode SDK v2, properties like `reasoning`, `temperature`, and `toolcall` (no underscore), as well as input modalities, are nested under a `capabilities` property rather than at the root level. The current resolver only checks root-level properties (e.g., `runtimeModel["tool_call"]`, `runtimeModel["reasoning"]`) and expects string arrays for `modalities`, which breaks compatibility with the v2 SDK structure.</violation>
</file>
<file name="src/shared/model-capabilities-cache.ts">
<violation number="1" location="src/shared/model-capabilities-cache.ts:90">
P2: merge logic always creates `modalities`/`limit` objects, turning absent optional fields into empty `{}` and violating the snapshot normalization invariant.</violation>
</file>
<file name="src/shared/connected-providers-cache.ts">
<violation number="1" location="src/shared/connected-providers-cache.ts:201">
P1: Spread order allows `rawMetadata.id` to overwrite normalized `id`, breaking metadata ID normalization and lookups.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
@code-yeongyu addressed Cubic review in Fixed:
Verification:
All six Cubic threads are replied to and resolved. |
|
Correction on the follow-up commit: |
Summary
models.devsnapshot plus a runtime cache/refresh path for model capabilitiesvariant,reasoningEffort,thinking,maxTokens,temperature, andtopPrefresh-model-capabilitiesCLI command, config schema support, and focused regression testsVerification
bun test src/shared/model-capabilities-cache.test.ts src/plugin/chat-params.test.ts --bailbun test src/shared/model-capabilities.test.ts src/shared/model-capabilities-cache.test.ts src/shared/model-settings-compatibility.test.ts src/shared/connected-providers-cache.test.ts src/plugin/chat-params.test.ts src/hooks/auto-update-checker/hook.test.ts src/cli/refresh-model-capabilities.test.ts src/config/schema.test.ts --bailbunx tsc --noEmitbun run buildgit diff --checkNote
bun test --bailstill hitssrc/tools/task/todo-sync.test.ts, but that failure is already present on cleanupstream/devand is unrelated to this PR.Summary by cubic
Adds a bundled
models.devsnapshot and a runtime cache/refresh for model capabilities, then uses it to normalize chat params and provider metadata. This drops unsupported settings, clamps limits, and enables auto-refresh on startup.New Features
src/generated/model-capabilities.generated.jsonand a cache store with refresh fromhttps://models.dev/api.json(script:build:model-capabilities).getModelCapabilitiesplus updated compatibility logic to handlevariant,reasoningEffort,thinking,maxTokens,temperature, andtopP.chat-paramsnow drops unsupported fields and clampsmaxTokens.refresh-model-capabilities(options:--directory,--source-url,--json).model_capabilities.{enabled,auto_refresh_on_start,refresh_timeout_ms,source_url}.findProviderModelMetadata.Migration
refresh-model-capabilities(optionally--source-url <URL>).model_capabilities: setenabled,auto_refresh_on_start,refresh_timeout_ms, orsource_url.Written for commit 2af9324. Summary will update on new commits.