Skip to content

fix: scope Anthropic effort fallback profile to non-Kimi providers - #1765

Merged
RealKai42 merged 4 commits into
mainfrom
fix/kimi-provider-effort-fallback
Jul 16, 2026
Merged

fix: scope Anthropic effort fallback profile to non-Kimi providers#1765
RealKai42 merged 4 commits into
mainfrom
fix/kimi-provider-effort-fallback

Conversation

@RealKai42

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue. This fixes a regression introduced by #1746.

Problem

#1746 added an inferred Anthropic effort profile (latest-Opus efforts as fallback for unrecognized model names) to fix custom-named third-party Anthropic-compatible endpoints. However, the inference also triggered for Kimi providers whose models are routed through the Anthropic protocol: managed Kimi models carry protocol = "anthropic" and do not declare think_efforts in the catalog, so they silently gained a synthetic effort list (low/medium/high/xhigh/max with default high) plus a thinking capability. The TUI model picker, /effort, the model catalog API, and ACP clients all displayed reasoning effort choices the server never declared (e.g. for kimi-for-coding).

What changed

  • effectiveModelAlias (v1) / effectiveModelConfig (v2) now take the provider type instead of an anthropicCompatible boolean. The inferred fallback profile applies only when the provider type is known, non-kimi, and the effective wire protocol is Anthropic; the previous self-trigger on the model-level protocol: 'anthropic' override is gone. Kimi providers — including managed models routed through protocol = "anthropic" — keep only catalog-declared efforts, and callers without provider context fall back to name matching only.
  • Threaded the provider type through the v1 provider manager and model catalog, the v2 model resolver and model catalog, the TUI model picker / /effort, and the ACP model catalog (providerless v2 models use their own protocol as the provider identity).
  • Wire behavior is unchanged: kosong still receives declared support_efforts, and Kimi providers keep kimiThinking-driven adaptive thinking regardless of the catalog display.
  • Reshaped the test assertions that encoded the old behavior (provider fixtures now use a non-Kimi Anthropic provider for the fallback cases) and added Kimi-provider regressions at every layer: v1/v2 unit, catalog service, model resolver, TUI message flow, and ACP config options.

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.

Managed Kimi models routed through the Anthropic protocol (protocol =
"anthropic", no catalog-declared think_efforts) inherited the inferred
latest-Opus effort profile, so the UI showed reasoning effort choices the
server never declared. The fallback now applies only when the provider type
is known, non-kimi, and the effective wire protocol is Anthropic; Kimi
providers keep catalog-declared efforts only, and callers without provider
context fall back to name matching.
@changeset-bot

changeset-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9811bca

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 16, 2026

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

commit: 9811bca

@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: cddfcfde14

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

Comment thread packages/agent-core-v2/src/app/modelCatalog/modelCatalogService.ts Outdated
Flat models (inline base_url, no named provider) and providers without a
declared type now fall back to the model's own protocol when deciding the
Anthropic fallback effort profile, so the model catalog stays consistent
with runtime resolution.

@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: 56747c8e61

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

@@ -47,7 +47,7 @@ function currentTuiConfig(host: SlashCommandHost): TuiConfig {

function effectiveModelForHost(host: SlashCommandHost, model: ModelAlias): ModelAlias {
const providerType = host.state.appState.availableProviders[model.provider]?.type;

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 flat Anthropic efforts in the TUI

When the TUI is backed by a v2 flat model (baseUrl plus protocol: 'anthropic' and no provider), model.provider is undefined here, so this passes no provider context. After this commit effectiveModelAlias no longer infers the Anthropic fallback from protocol alone, while ModelResolverService still does for the same flat model, so /effort and the model picker lose the supportEfforts choices even though the runtime resolves them. Fall back to model.protocol when no provider type is available.

Useful? React with 👍 / 👎.

const providerName = alias.provider ?? config.defaultProvider;
if (providerName === undefined) return false;
return config.providers?.[providerName]?.type === 'anthropic';
if (providerName === undefined) return undefined;

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 flat Anthropic efforts in ACP catalog

For ACP sessions whose harness config comes from a v2 flat Anthropic model with no named provider, this returns undefined, and the updated effectiveModelAlias no longer self-triggers from protocol: 'anthropic'. listModelsFromHarness therefore omits thinkingSupported and keeps defaultThinkingEffort as on, while the v2 resolver still infers the latest Anthropic effort profile for that same model. Return the alias protocol as the provider identity when no provider name is present.

Useful? React with 👍 / 👎.

Flat models without a named provider (inline base_url, protocol:
"anthropic") have no provider entry to look up; fall back to the
model's own protocol as the provider identity so the effort picker and
ACP catalog stay consistent with runtime resolution.
@RealKai42

Copy link
Copy Markdown
Collaborator Author

@codex

@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: 0ac9577b30

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

export function effectiveModelAlias(
alias: ModelAlias,
anthropicCompatible = false,
providerType?: ProviderType,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve the exported boolean compatibility flag

Because effectiveModelAlias is re-exported by @moonshot-ai/kimi-code-sdk (packages/node-sdk/src/index.ts), changing its second parameter from the previous boolean to ProviderType breaks existing callers that pass true for Anthropic-compatible aliases; TypeScript consumers get a signature break and JavaScript callers silently stop receiving inferred fallback efforts. Please keep a boolean-compatible overload/path or introduce the provider-type variant without changing this exported call shape in a patch.

Useful? React with 👍 / 👎.

Comment on lines +98 to +102
// The inferred fallback profile exists for third-party Anthropic-compatible
// endpoints whose model name encodes no known Claude version. Kimi providers
// — including managed models routed through protocol = "anthropic" — declare
// thinking efforts via the catalog, so they never receive the fallback.
// Callers without provider context fall back to name matching only.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove inline v2 implementation comments

The v2 guide in packages/agent-core-v2/AGENTS.md says comments must live solely in the top-of-file block and never beside functions, methods, or statements; this new inline rationale violates that rule, as do the same newly added inline explanations in modelResolverService.ts and modelCatalogService.ts. Please remove these comments or move durable rationale into the file header.

Useful? React with 👍 / 👎.

The v2 comment convention keeps comments in the top-of-file block only;
drop the inline explanations added beside functions and statements.
@RealKai42
RealKai42 merged commit d531398 into main Jul 16, 2026
14 checks passed
@RealKai42
RealKai42 deleted the fix/kimi-provider-effort-fallback branch July 16, 2026 09:30
This was referenced Jul 16, 2026
ywh114 pushed a commit to ywh114/kimi-code that referenced this pull request Jul 19, 2026
…oonshotAI#1765)

* fix: scope Anthropic effort fallback profile to non-Kimi providers

Managed Kimi models routed through the Anthropic protocol (protocol =
"anthropic", no catalog-declared think_efforts) inherited the inferred
latest-Opus effort profile, so the UI showed reasoning effort choices the
server never declared. The fallback now applies only when the provider type
is known, non-kimi, and the effective wire protocol is Anthropic; Kimi
providers keep catalog-declared efforts only, and callers without provider
context fall back to name matching.

* fix: align v2 catalog with resolver for providerless Anthropic models

Flat models (inline base_url, no named provider) and providers without a
declared type now fall back to the model's own protocol when deciding the
Anthropic fallback effort profile, so the model catalog stays consistent
with runtime resolution.

* fix: keep flat Anthropic model effort metadata in TUI and ACP catalogs

Flat models without a named provider (inline base_url, protocol:
"anthropic") have no provider entry to look up; fall back to the
model's own protocol as the provider identity so the effort picker and
ACP catalog stay consistent with runtime resolution.

* style: move v2 anthropic fallback rationale into the modelAuth header

The v2 comment convention keeps comments in the top-of-file block only;
drop the inline explanations added beside functions and statements.
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