Skip to content

refactor: move Kimi for Coding provider to SDK#281

Merged
wbxl2000 merged 1 commit into
mainfrom
xtr/move-kimi-provider-to-sdk
Jun 1, 2026
Merged

refactor: move Kimi for Coding provider to SDK#281
wbxl2000 merged 1 commit into
mainfrom
xtr/move-kimi-provider-to-sdk

Conversation

@kermanx
Copy link
Copy Markdown
Collaborator

@kermanx kermanx commented Jun 1, 2026

Related Issue

No linked issue. The problem is described below.

Problem

KimiForCodingProvider is SDK-specific because it wires Kimi Code OAuth credentials, Kimi Code request headers, and the managed Kimi Code base URL into a ModelProvider. Keeping that implementation under agent-core crosses the package boundary and makes core carry SDK/OAuth-specific provider construction.

What changed

  • Added KimiForCodingProvider in packages/node-sdk/src/kimi-code-model-provider.ts.
  • Exported KimiForCodingProvider and KimiForCodingProviderOptions from the SDK entry point.
  • Exported ResolvedRuntimeProvider from the agent-core public entry point so the SDK provider can implement the public ModelProvider contract without importing from an internal source path.

Validation

  • pnpm --filter @moonshot-ai/kimi-code-sdk run typecheck
  • pnpm --filter @moonshot-ai/agent-core run typecheck
  • pnpm --filter @moonshot-ai/kimi-code-sdk run build

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 1, 2026

⚠️ No Changeset found

Latest commit: 1feb1a2

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 1, 2026

pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@1feb1a2
npx https://pkg.pr.new/@moonshot-ai/kimi-code@1feb1a2

commit: 1feb1a2

Copy link
Copy Markdown

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

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: 1feb1a23a4

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

}

private async buildAuth(force: boolean): Promise<ProviderRequestAuth> {
const apiKey = await this.toolkit.ensureFresh(KIMI_CODE_PROVIDER_NAME, { force });
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 Preserve login-required errors from OAuth refresh

When the user has no stored token or the refresh token is revoked, KimiOAuthToolkit.ensureFresh throws OAuthError/OAuthUnauthorizedError; letting that escape here means Agent error normalization classifies the failed prompt as internal rather than auth.login_required, so SDK callers using this provider won't get the login-required code that existing ProviderManager-based OAuth paths provide. Wrap ensureFresh failures (and any blank token) in KimiError(ErrorCodes.AUTH_LOGIN_REQUIRED, ...) before returning auth.

Useful? React with 👍 / 👎.

return {
providerName: 'kimi-for-coding',
provider,
modelCapabilities: UNKNOWN_CAPABILITY,
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 Preserve Kimi for Coding capabilities

When SDK callers use this provider directly, returning UNKNOWN_CAPABILITY leaves max_context_tokens at 0 and all modality flags false. The agent's compaction strategy treats maxSize <= 0 as never compact, and ToolManager only registers ReadMediaFile when image/video caps are true, so this regresses long-session compaction and media-file support compared with the managed Kimi Code config that declares Kimi for Coding's context length and capabilities.

Useful? React with 👍 / 👎.

@wbxl2000 wbxl2000 merged commit ab54641 into main Jun 1, 2026
17 checks passed
@wbxl2000 wbxl2000 deleted the xtr/move-kimi-provider-to-sdk branch June 1, 2026 12:44
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.

2 participants