feat(managed-kimi-code): route anthropic protocol via beta api#1182
feat(managed-kimi-code): route anthropic protocol via beta api#1182sailist wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 6fd0ebb 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 |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 177823d8fa
ℹ️ 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".
| let newBetas = [...(this._generationKwargs.betaFeatures ?? [])]; | ||
|
|
||
| if (adaptive) { | ||
| if (adaptive && !this._explicitBetaFeatures) { |
There was a problem hiding this comment.
Preserve adaptive thinking with explicit betas
When config comes from managed Kimi Code, packages/oauth/src/managed-kimi-code.ts now sets both betaFeatures and adaptiveThinking: true for thinking-capable Anthropic-protocol models. This condition makes withThinking('high') skip the adaptive branch whenever beta features are explicit, so requests fall through to thinking: { type: 'enabled', budget_tokens: ... } (and max can throw in budgetTokensForEffort) instead of the type: 'adaptive' payload that Kimi's Anthropic-compatible endpoint requires. Keep beta-list preservation separate from selecting the adaptive thinking payload.
Useful? React with 👍 / 👎.
- kosong: add betaApi option to use client.beta.messages.create - agent-core: thread alias betaApi into the anthropic provider config - oauth: route managed models on the anthropic protocol through the beta Messages API
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6fd0ebb979
ℹ️ 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".
| // remove before commit | ||
| const adaptiveThinkingOverride = this.options.adaptiveThinkingOverride?.(); | ||
| const effectiveAdaptiveThinking = adaptiveThinkingOverride ?? alias.adaptiveThinking; |
There was a problem hiding this comment.
Remove the leftover adaptive-thinking override hook
When a ProviderManager is constructed with this new option, it replaces alias.adaptiveThinking for every resolved model, so a test/debug hook left enabled in any runtime path silently ignores the per-model config this code is trying to thread through. The inline remove before commit marker suggests this was not intended; please drop the option and pass alias.adaptiveThinking directly.
Useful? React with 👍 / 👎.
Related Issue
N/A — no prior issue; the problem is described below.
Problem
Managed Kimi Code models that declare the Anthropic-compatible protocol (
protocol: 'anthropic') are currently served through the standard Messages API (POST /v1/messages). Kimi's anthropic-compatible endpoint is actually backed by the beta Messages API (POST /v1/messages?beta=true), so these models need to be routed through the beta endpoint to behave correctly.What changed
AnthropicChatProvidergains abetaApioption. When enabled, requests go throughclient.beta.messages.create(POST /v1/messages?beta=true) instead of the standardclient.messages.create.ModelAliasgains abetaApiflag, threaded through to the anthropic provider config alongside the existingadaptiveThinkingoverride.betaApi: trueon every model that declaresprotocol: 'anthropic'.Non-managed Anthropic providers (official
api.anthropic.com, OpenRouter, etc.) are unaffected:betaApidefaults to off and the existing standard-endpoint behavior is unchanged.Tests added/updated in kosong, agent-core, and oauth; all three packages pass tests and
tsc --noEmit.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.