Skip to content

feat(agent): adaptive thinking for Kimi-family Anthropic endpoints - #67231

Closed
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:feat/67228-adaptive-thinking-kimi
Closed

feat(agent): adaptive thinking for Kimi-family Anthropic endpoints#67231
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:feat/67228-adaptive-thinking-kimi

Conversation

@webtecnica

@webtecnica webtecnica commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Kimi's Anthropic-compatible endpoints (api.moonshot.cn/anthropic, api.kimi.com/coding) implement the adaptive thinking contract — they accept thinking.type=adaptive + output_config.effort (all of low, medium, high, xhigh, max verified live) and return thinking blocks, and the replay-validation 400s that originally motivated dropping the parameter (#13848) no longer occur.

_supports_adaptive_thinking() now returns True for Kimi-family models, so they get thinking={type: adaptive, display: summarized} + output_config.effort via ADAPTIVE_EFFORT_MAP instead of nothing, and the blanket drop of the thinking parameter for Kimi-family endpoints is removed. MiniMax and other non-adaptive third parties keep the manual budget_tokens path; Claude behavior is unchanged.

What does this PR do?

Kimi's Anthropic-compatible endpoints (api.moonshot.cn/anthropic, api.kimi.com/coding) implement the adaptive thinking contract. Stop dropping the thinking parameter for the Kimi family and send it in adaptive form.

Related Issue

Fixes #67228

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • _supports_adaptive_thinking() returns True for Kimi-family models → thinking={type: adaptive, display: summarized} + output_config.effort via ADAPTIVE_EFFORT_MAP (never manual budget_tokens)
  • the blanket drop of the thinking parameter for Kimi-family endpoints ([Bug]: 400 error for kimi-for-coding #13848-era mitigation) is removed
  • MiniMax and other non-adaptive third parties keep the manual budget_tokens path; Claude behavior unchanged

How to Test

Test it against the kimi for coding endpoint:

  • thinking.type="adaptive" + output_config.effort in {low, medium, high, xhigh, max} → all HTTP 200 with thinking blocks; display="summarized" accepted
  • multi-turn tool-call replays in every history shape — signed thinking blocks verbatim, unsigned placeholder blocks, and no thinking blocks at all (the exact [Bug]: 400 error for kimi-for-coding #13848 trigger) — all return HTTP 200; the replay-validation 400s that motivated the original drop no longer occur

Checklist

  • Commit messages follow Conventional Commits
  • All tests pass
  • Tests added for the changes
  • No unrelated commits

Kimi's Anthropic-compatible endpoints (api.moonshot.cn/anthropic,
api.kimi.com/coding) now implement the adaptive thinking contract
(thinking.type="adaptive" + output_config.effort), and the
replay-validation 400s that originally motivated dropping the
thinking parameter (NousResearch#13848) no longer occur.

- _supports_adaptive_thinking() returns True for Kimi-family models
- Remove blanket Kimi thinking suppression in build_anthropic_kwargs()
- MiniMax and other non-adaptive third parties keep the manual
  budget_tokens path; Claude behavior unchanged
- Update tests: Kimi gets adaptive thinking, effort mapping verified

Closes NousResearch#67228
@webtecnica
webtecnica force-pushed the feat/67228-adaptive-thinking-kimi branch from 5b1a3e0 to 75578f4 Compare July 19, 2026 01:19
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/kimi Kimi / Moonshot P2 Medium — degraded but workaround exists needs-decision Awaiting maintainer decision before any implementation duplicate This issue or pull request already exists labels Jul 19, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #67228: the production adaptive-thinking change is the same; only test-comment whitespace differs. The endpoint-contract decision noted on #67228 still applies.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for isolating the Kimi change and retaining the existing replay coverage. Current main still suppresses Anthropic thinking for Kimi-family endpoints at agent/anthropic_adapter.py:2647-2649; this PR changes that exact path by classifying Kimi models as adaptive at agent/anthropic_adapter.py:255-256 and allowing the normal adaptive mapping at agent/anthropic_adapter.py:2648-2664.

The PR tests cover official and proxied Kimi-family endpoint shapes, effort mapping, disabled thinking, and retain the unsigned replay regression at tests/agent/test_kimi_coding_anthropic_thinking.py:172-209. No code-level blocking issue was found in static review.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jul 19, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Closing as an exact duplicate of #67228 — the two diffs are byte-identical (same adapter change, same tests) and #67228 was submitted first (01:03 vs 01:11 UTC). Consolidating review onto #67228; if it lands, both approaches are covered since they're the same change. Thanks for the contribution — please coordinate on #67228 going forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists needs-decision Awaiting maintainer decision before any implementation P2 Medium — degraded but workaround exists provider/kimi Kimi / Moonshot sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants