Skip to content

Infer the Anthropic wire from a provider's /anthropic endpoint path - #2371

Open
octo-patch wants to merge 1 commit into
MoonshotAI:mainfrom
octo-patch:octo/20260729-parameter-refresh-recvq9XdO7hwrM
Open

Infer the Anthropic wire from a provider's /anthropic endpoint path#2371
octo-patch wants to merge 1 commit into
MoonshotAI:mainfrom
octo-patch:octo/20260729-parameter-refresh-recvq9XdO7hwrM

Conversation

@octo-patch

Copy link
Copy Markdown

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 / resolveModelsDevImport decide a provider's wire from type, npm, and id only — never from the declared endpoint (api). A provider that exposes its Anthropic-compatible surface under a /anthropic path, but has no explicit type: "anthropic" and no anthropic/claude token in its npm/id, falls through every heuristic to the OpenAI-compatible fallback. Because a concrete api is present, the Anthropic endpoint is then persisted verbatim under the OpenAI wire — an incompatible { type: "openai", baseUrl: ".../anthropic" } pair, surfaced only by guessed: true.

Change

  • Infer the Anthropic wire from the declared endpoint when nothing else names it: a bare /anthropic path segment (the convention OpenAI-first vendors use to expose the Anthropic wire) now resolves to anthropic with guessed: false and stores the endpoint under the Anthropic wire. Matching is on the URL path only, so a host such as api.anthropic.com (path /v1) is left to the existing id/npm checks.
  • Applied identically to both lockstep copies of the resolver: packages/kosong/src/catalog.ts and packages/agent-core-v2/src/app/kosongConfig/modelsDev.ts.
  • Added unit coverage in packages/kosong/test/catalog.test.ts and an import integration test in packages/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 passed
  • tsc -p packages/kosong/tsconfig.json --noEmit — clean
  • tsc -p packages/agent-core-v2/tsconfig.json --noEmit — clean
  • oxlint on the changed files — no new errors

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.
@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 83e27aa

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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