feat(agent-core-v2): fall back to models.dev catalog for model capability detection - #1660
Open
7Sageer wants to merge 1 commit into
Open
feat(agent-core-v2): fall back to models.dev catalog for model capability detection#16607Sageer wants to merge 1 commit into
7Sageer wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: f23a69a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
5 tasks
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.
Related Issue
No linked issue — the problem is explained below.
Problem
Model capability detection for non-Kimi providers (
image_in/video_in/audio_in/thinking/tool_use) relied solely on a hardcoded prefix table inllmProtocol/providers/capability-registry.ts. That table is effectively unmaintained: a new model only gets correct capability gating when someone hand-adds a prefix, and everything else falls through toUNKNOWN_CAPABILITY.Meanwhile the CLI already bundles a models.dev catalog snapshot (
BUILT_IN_CATALOG_JSON, injected at release build time) with rich, community-maintained per-model capability data — but it had zero runtime consumers.What changed
resolveModelCapabilitiesin agent-core-v2 now consults the bundled catalog before the hardcoded table. The precedence chain is:config declaration (
alias.capabilities) > models.dev catalog lookup > hardcoded prefix table > UNKNOWNllmProtocol/catalog.ts: newgetCatalogModelCapability(catalog, protocol, modelName)— maps each wire type to its first-party models.dev provider id (anthropic/openai/google/google-vertex(+-anthropic); the kimi wire is not mapped), normalizes catalog model keys (Bedrock region/vendor prefixes, Vertex@version,-v1:0, date suffixes), and returns the catalog capability on a normalized exact match. Also addsloadBuiltInCatalogfor parsing a snapshot JSON string.llmProtocol/catalogSnapshot.ts: newICatalogSnapshotapp-scope DI token so hosts inject catalog data (agent-core-v2 stays dependency-free at L0).model/modelResolverService.ts:detected = getCatalogModelCapability(...) ?? getModelCapability(...);select_toolsandmax_context_tokenssemantics are unchanged.kap-server:ServerStartOptions.catalogseeds the snapshot at bootstrap.apps/kimi-codeserver startup (v2 path): loadsBUILT_IN_CATALOG_JSONand passes it through. Dev builds ship no snapshot, so they fall back to the hardcoded table exactly as before.Notes for reviewers:
maxContextSize), so per-provider limit differences (e.g. Azure's smaller context windows) are out of scope here.lint:domainclean.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update (internal fallback only; no user-facing config or behavior change).