Skip to content

fix: align Anthropic-compatible model capabilities - #1746

Merged
RealKai42 merged 10 commits into
mainfrom
kaiyi/fix-anthropic-effort-detection
Jul 15, 2026
Merged

fix: align Anthropic-compatible model capabilities#1746
RealKai42 merged 10 commits into
mainfrom
kaiyi/fix-anthropic-effort-detection

Conversation

@RealKai42

@RealKai42 RealKai42 commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue. This fixes a reproducible Anthropic-compatible provider regression during model switching and session resume.

Problem

Anthropic-compatible models with custom names were treated as legacy budget-thinking Claude models. Valid backend-specific efforts such as max or high could therefore be rejected or normalized before reaching the backend. The same validation could abort session resume while replaying a historical effort that no longer appeared in the current support_efforts metadata.

Preserved-thinking sessions had a second failure mode: with keep = "all", strict compatible endpoints rejected replayed assistant messages that had text but no thinking block.

What changed

  • Add the official Anthropic model effort profiles and use the latest Opus effort profile plus a 128k output fallback for unknown Anthropic-compatible model names.
  • Propagate model-declared support_efforts through the v1 and v2 model catalogs and expose the inferred choices in the TUI.
  • Treat support_efforts as advisory for the actual Anthropic wire protocol: emit a warning, preserve the requested effort unchanged, and let the configured backend validate it. Native Kimi and other protocols retain strict client-side validation.
  • Base effort validation and always_thinking behavior on the actual wire protocol, including Kimi-managed models with protocol = "anthropic".
  • Queue replay-time warnings until restore completes so cold resume remains silent while rebuilding state, then deliver the warning without allowing logging or event-sink failures to block resume.
  • When preserved thinking keeps all history, synthesize an empty thinking block only for non-Claude compatible models whose assistant history is missing one; disabled thinking and official Claude models remain unchanged.
  • Add provider, model-catalog, TUI, live-send, and cold-resume regressions across both engines.

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.

Validation

  • Four-project full suite: 688 files passed, 4 skipped; 10,864 tests passed, 3 expected failures, 32 skipped, 1 todo. Two unrelated flaky failures on the post-merge run passed when rerun individually (51/51).
  • Targeted Anthropic/model/TUI/resume suite: 700/700 passed before the final cold-resume assertions; final cold-resume and warning-sink tests: 31/31 passed.
  • Typecheck: @moonshot-ai/kosong, @moonshot-ai/agent-core, @moonshot-ai/agent-core-v2, and @moonshot-ai/kimi-code.
  • agent-core-v2 domain-layer check.
  • Full repository lint: 0 errors (existing warnings remain).
  • Builds: Kosong, agent-core v1, agent-core v2, and the CLI bundle.
  • Workspace consistency, package publication lint, and changeset status checks.

@changeset-bot

changeset-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 787a838

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

@RealKai42
RealKai42 marked this pull request as ready for review July 15, 2026 09:26
@pkg-pr-new

pkg-pr-new Bot commented Jul 15, 2026

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

commit: f2b5fbf

@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: 83ebc583e1

ℹ️ 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/kosong/src/providers/anthropic.ts Outdated
Comment thread packages/kosong/src/providers/anthropic.ts Outdated

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

ℹ️ 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/kosong/src/providers/anthropic-profile.ts

@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: 786f7b0fb1

ℹ️ 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/src/config/model.ts
Comment thread packages/agent-core-v2/src/agent/llmRequester/llmRequesterService.ts Outdated

@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: 0070c40ca1

ℹ️ 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/src/config/model.ts
Comment thread packages/agent-core-v2/src/agent/profile/profileService.ts

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

ℹ️ 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/kosong/src/providers/anthropic.ts

@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: 787a838727

ℹ️ 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/src/config/model.ts
Comment thread packages/kosong/src/providers/anthropic.ts
@RealKai42
RealKai42 merged commit 918c135 into main Jul 15, 2026
14 checks passed
@RealKai42
RealKai42 deleted the kaiyi/fix-anthropic-effort-detection branch July 15, 2026 17:31
@github-actions github-actions Bot mentioned this pull request Jul 15, 2026
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Jul 15, 2026
* fix: align Anthropic-compatible model capabilities

* fix: warn on Anthropic effort mismatches

* fix: harden Anthropic model resolution

* fix: align Anthropic replay and ACP thinking state

* fix: normalize Anthropic thinking stream payloads

* fix: backfill non-empty preserved thinking

* fix: resolve session thinking effort with provider context

* fix: honor adaptive thinking opt-out in effort resolution
7723qqq added a commit to 7723qqq/kimi-code that referenced this pull request Jul 15, 2026
…oonshotAI#1676 MoonshotAI#1625 MoonshotAI#1746 MoonshotAI#1753 MoonshotAI#1757)

Critical fixes cherry-picked from upstream v0.24.x:
- fix(agent-core-v2): align rate-limit retries with v1 (MoonshotAI#1598)
- fix: preserve empty reasoning across providers (MoonshotAI#1676)
- fix: resolve and synchronize thinking effort (MoonshotAI#1625)
- fix: align Anthropic-compatible model capabilities (MoonshotAI#1746)
- fix(kap-server): close auth bypass via percent-encoded API paths (MoonshotAI#1753)
- fix: preserve the crash error in diagnostic logs on unexpected exit (MoonshotAI#1757)
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