fix: scope Anthropic effort fallback profile to non-Kimi providers - #1765
Conversation
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 detectedLatest commit: 9811bca 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: 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".
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.
There was a problem hiding this comment.
💡 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; | |||
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
💡 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, |
There was a problem hiding this comment.
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 👍 / 👎.
| // 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. |
There was a problem hiding this comment.
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.
…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.
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 declarethink_effortsin the catalog, so they silently gained a synthetic effort list (low/medium/high/xhigh/maxwith defaulthigh) plus athinkingcapability. 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 ananthropicCompatibleboolean. 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-levelprotocol: 'anthropic'override is gone. Kimi providers — including managed models routed throughprotocol = "anthropic"— keep only catalog-declared efforts, and callers without provider context fall back to name matching only./effort, and the ACP model catalog (providerless v2 models use their ownprotocolas the provider identity).support_efforts, and Kimi providers keepkimiThinking-driven adaptive thinking regardless of the catalog display.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.