Infer the Anthropic wire from a provider's /anthropic endpoint path - #2371
Infer the Anthropic wire from a provider's /anthropic endpoint path#2371octo-patch wants to merge 1 commit into
Conversation
The models.dev catalog resolver decided a provider's wire from type/npm/id only. A provider exposing its Anthropic-compatible surface under a /anthropic path, without an explicit type or an anthropic/claude token in npm/id, fell through to the OpenAI-compatible fallback and persisted the Anthropic endpoint under the OpenAI wire. Infer the Anthropic wire from a /anthropic endpoint path segment (matched on the path only), in both lockstep copies of the resolver, with unit and import-integration coverage.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 83e27aa426
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| }, | ||
| }, | ||
| 'anthropic-gateway': { | ||
| id: 'anthropic-gateway', |
There was a problem hiding this comment.
Use a neutral id in the endpoint-path fixture
This new fixture still contains anthropic in the provider id, so the existing id.includes('anthropic') heuristic makes getModelsDevProvider() and the import assertions pass even if the new /anthropic endpoint-path detection in the v2 resolver is removed or broken. Since this test is meant to guard the agent-core-v2 lockstep copy, rename the catalog key/id to a neutral value while keeping the /anthropic API path.
Useful? React with 👍 / 👎.
Reason: The models.dev catalog import miswires a provider whose endpoint declares the Anthropic protocol in its path but omits an explicit type.
Problem
resolveCatalogImport/resolveModelsDevImportdecide a provider's wire fromtype,npm, andidonly — never from the declared endpoint (api). A provider that exposes its Anthropic-compatible surface under a/anthropicpath, but has no explicittype: "anthropic"and noanthropic/claudetoken in itsnpm/id, falls through every heuristic to the OpenAI-compatible fallback. Because a concreteapiis present, the Anthropic endpoint is then persisted verbatim under the OpenAI wire — an incompatible{ type: "openai", baseUrl: ".../anthropic" }pair, surfaced only byguessed: true.Change
/anthropicpath segment (the convention OpenAI-first vendors use to expose the Anthropic wire) now resolves toanthropicwithguessed: falseand stores the endpoint under the Anthropic wire. Matching is on the URL path only, so a host such asapi.anthropic.com(path/v1) is left to the existingid/npmchecks.packages/kosong/src/catalog.tsandpackages/agent-core-v2/src/app/kosongConfig/modelsDev.ts.packages/kosong/test/catalog.test.tsand an import integration test inpackages/agent-core-v2/test/app/kosongConfig/modelsDevImport.test.ts.Checks
vitest run packages/kosong/test/catalog.test.ts packages/agent-core-v2/test/app/kosongConfig/modelsDevImport.test.ts— 66 passedtsc -p packages/kosong/tsconfig.json --noEmit— cleantsc -p packages/agent-core-v2/tsconfig.json --noEmit— cleanoxlinton the changed files — no new errors