Skip to content

fix: import google-genai providers from custom registries - #4735

Merged
7Sageer merged 1 commit into
mainfrom
fix/google-genai-custom-registry
Nov 6, 2026
Merged

7Sageer merged 1 commit into
mainfrom
fix/google-genai-custom-registry

Conversation

@7Sageer

@7Sageer 7Sageer commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Requirement or Bug

Custom registries that publish a google-genai provider were silently dropped on import. A document containing only that provider failed with "has no importable providers".

Bug Reproduction Steps

  1. Point a custom registry at an api.json whose only provider has "type": "google-genai" and "api": "https://gateway.example.test/v1beta".
  2. Import it with /provider or kimi provider.
  3. The import fails because the entry is skipped as an unsupported type.

Root Cause

The registry parser accepted only anthropic, openai, openai_responses, and kimi, even though the engine already implements google-genai. Allowing the type alone was not enough: @google/genai appends its default API version to baseUrl, so an endpoint that already ends in /v1beta would be requested at /v1beta/v1beta/.... This strips that trailing version before constructing the client.

Code Changes

fetchCustomRegistry now keeps google-genai entries, and the Gemini client strips a trailing /v1beta (or /v1beta1 on the Vertex path) from baseUrl before handing it to the SDK. The SDK still appends the version itself, so both a host root and a versioned registry URL resolve to the same request path.

 fetchCustomRegistry
   allowed types
-    anthropic, openai, openai_responses, kimi
+    anthropic, openai, openai_responses, google-genai, kimi

 createClient(baseUrl)
+  strip trailing /v1beta or /v1beta1
   pass baseUrl to @google/genai
   SDK appends the version and :generateContent path

vertexai remains outside the registry allowlist. The credential is still sent as x-goog-api-key.

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
api.json entry with type: google-genai skipped; a document of only that type fails import imported as a google-genai provider nobody; the type was unusable through registries none
google-genai base_url ending in /v1beta SDK requests /v1beta/v1beta/... trailing version stripped, then SDK appends it once hand-written configs that already omitted /v1beta keep working; configs that included it and depended on the doubled path stop hitting that path set base_url to the previous doubled path if a gateway actually serves it
Vertex base_url ending in /v1beta1 SDK requests /v1beta1/v1beta1/... trailing version stripped the same way same population, on the Vertex path same

Affected modules: custom-registry import (packages/oauth) and the Gemini protocol client (packages/agent-core-v2). Covered by the registry parser test and the client base-URL cases. A live import of a versioned Gemini registry endpoint returned a model response through the patched client.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Copilot AI balanced review requested due to automatic review settings November 6, 2026 10:09
@changeset-bot

changeset-bot Bot commented Nov 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d4433e0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

@7Hanrui

7Hanrui commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

@codex review

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T10:11:49.857055Z d4433e0 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 6, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@d4433e0
npx https://pkg.pr.new/@moonshot-ai/kimi-code@d4433e0

commit: d4433e0

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: d4433e0ef9

ℹ️ 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".

@7Sageer
7Sageer merged commit bc6fa89 into main Nov 6, 2026
17 checks passed
@7Sageer
7Sageer deleted the fix/google-genai-custom-registry branch November 6, 2026 11:06
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.

4 participants