feat(managed-kimi-code): route anthropic protocol via beta api#1186
Merged
Conversation
- 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
- Add KIMI_CODE_CUSTOM_HEADERS env var for custom outbound LLM headers - Send User-Agent to non-Kimi providers - Forward Kimi identity headers to model catalog fetches - Support defaultHeaders in Google GenAI provider
- Add type/protocol/alias to api_error for per-protocol error attribution - Add turn_ended event with reason/duration/mode/type/protocol - Add type/protocol to turn_interrupted
🦋 Changeset detectedLatest commit: 103d600 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: 461b0c4e96
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Merged
liruifengv
added a commit
that referenced
this pull request
Jun 29, 2026
Resolve conflicts with main's #1186 (managed-kimi-code anthropic beta-api routing): - packages/oauth/src/managed-kimi-code.ts: keep this branch's selective-merge model refresh and effort fields, layer in main's betaApi/adaptiveThinking. Both are assigned directly (cleared when the server stops declaring anthropic) so they never go stale across refreshes, mirroring how protocol is handled. - packages/oauth/src/open-platform.ts: keep both imports (parseThinkEfforts for effort parsing, parseKimiCodeCustomHeaders for request headers). - packages/agent-core/src/session/provider-manager.ts: pass through both betaApi (anthropic) and supportEfforts (kimi); use main's effectiveAdaptiveThinking and envCustomHeaders. - packages/agent-core/src/config/schema.ts: keep both ModelAlias fields (supportEfforts/defaultEffort and betaApi).
Moixia
pushed a commit
to Moixia/idea
that referenced
this pull request
Jun 29, 2026
…hotAI#1186) * feat(managed-kimi-code): route anthropic protocol via beta api - 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 * feat(providers): add KIMI_CODE_CUSTOM_HEADERS support - Add KIMI_CODE_CUSTOM_HEADERS env var for custom outbound LLM headers - Send User-Agent to non-Kimi providers - Forward Kimi identity headers to model catalog fetches - Support defaultHeaders in Google GenAI provider * feat(agent-core): add protocol attrs to turn and api error telemetry - Add type/protocol/alias to api_error for per-protocol error attribution - Add turn_ended event with reason/duration/mode/type/protocol - Add type/protocol to turn_interrupted * chore(oauth): remove hardcoded internal dev endpoint from shared OAuth base URLs --------- Co-authored-by: haozhe.yang <yanghaozhe@moonshot.ai>
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. Opened from the in-repo
feat/anthropicbranch (supersedes the fork-based #1182).Problem
Managed Kimi Code models that declare the Anthropic-compatible protocol must be served through the Anthropic beta Messages API. Operators also need a way to inject custom outbound LLM headers, and to attribute turn and error telemetry by provider wire protocol so issues on this path can be isolated after rollout.
What changed
client.beta.messages.create); beta features are sent via the requestbetasfield instead of theanthropic-betaheader to avoid duplication. Thinking-capable Anthropic models are opted into adaptive thinking.KIMI_CODE_CUSTOM_HEADERS(newline-separatedName: Valuelines) for custom outbound LLM request headers, send the CLIUser-Agentto non-Kimi providers, forward Kimi identity headers to model catalog fetches, and supportdefaultHeadersin the Google GenAI provider.type/protocol(andalias) toapi_errorandturn_interrupted, and introduce aturn_endedtelemetry event, so turn volume, completion rate, and errors can be segmented by provider wire protocol.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.Note: the new
KIMI_CODE_CUSTOM_HEADERSenv var may need a user-facing docs update.