Skip to content

fix(agent): enable thinking for Kimi /coding endpoint via Anthropic Messages - #49143

Closed
www654cc-pixel wants to merge 1 commit into
NousResearch:mainfrom
www654cc-pixel:fix/kimi-coding-thinking
Closed

www654cc-pixel wants to merge 1 commit into
NousResearch:mainfrom
www654cc-pixel:fix/kimi-coding-thinking

Conversation

@www654cc-pixel

Copy link
Copy Markdown

The kimi-coding provider routes sk-kimi-* keys to https://api.kimi.com/coding and correctly uses anthropic_messages API mode. However, build_anthropic_kwargs() previously skipped the thinking parameter for all Kimi-family endpoints due to concerns that Kimi required reasoning_content on every replayed tool-call message in thinking mode.

I tested directly against the live https://api.kimi.com/coding/v1/messages endpoint:

  • Single-turn requests with thinking: {"type": "enabled"} return type: "thinking" blocks
  • Multi-turn replay with signed thinking blocks → 200 OK
  • Multi-turn replay with unsigned thinking blocks → 200 OK
  • Multi-turn replay without any thinking block → 200 OK
  • Tool-call conversations (thinking + tool_use + tool_result + follow-up) → 200 OK

Kimi no longer enforces the reasoning_content requirement that motivated the original exclusion. The existing _needs_thinking_reasoning_pad() and _manage_thinking_signatures() machinery already handles the echo-back for Kimi, so no additional changes are needed for multi-turn continuity.

Testing: I applied this fix locally and confirmed that Kimi K2.6 now displays reasoning/thinking output in Hermes agent.

@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 labels Jun 19, 2026
@www654cc-pixel

Copy link
Copy Markdown
Author

Hi @kshitijk4poor @teknium1 — could one of you take a look at this small fix when you have a moment?\n\nIt enables the parameter for the Kimi endpoint in , which was previously skipped for all Kimi-family providers. I validated the change directly against the live endpoint for single-turn, multi-turn replay (signed/unsigned/no thinking blocks), and tool-call conversations — all returned 200 OK.\n\nOnly one file changed (). Happy to address any feedback.

@www654cc-pixel

Copy link
Copy Markdown
Author

Hi @kshitijk4poor @teknium1 — could one of you take a look at this small fix when you have a moment?\n\nIt enables the thinking parameter for the Kimi /coding endpoint in build_anthropic_kwargs(), which was previously skipped for all Kimi-family providers. I validated the change directly against the live https://api.kimi.com/coding/v1/messages endpoint for single-turn, multi-turn replay (signed/unsigned/no thinking blocks), and tool-call conversations — all returned 200 OK.\n\nOnly one file changed (agent/anthropic_adapter.py). Happy to address any feedback.

…essages

The Kimi /coding endpoint uses the Anthropic Messages protocol
(/v1/messages). The build_anthropic_kwargs() function previously
skipped sending the thinking parameter for all Kimi-family endpoints
due to concerns that Kimi required reasoning_content on every
replayed tool-call message in thinking mode.

Empirical testing against the current Kimi /coding/v1/messages
endpoint shows this is no longer the case:
- Multi-turn replay with signed thinking blocks works.
- Multi-turn replay with unsigned thinking blocks works.
- Multi-turn replay without any thinking block works.
- Tool-call conversations work correctly.

Remove the Kimi exclusion so the thinking parameter is sent,
enabling reasoning display for Kimi Coding Plan subscribers.
@www654cc-pixel
www654cc-pixel force-pushed the fix/kimi-coding-thinking branch from 26d8ab8 to 9c40def Compare June 21, 2026 03:31
@www654cc-pixel

Copy link
Copy Markdown
Author

Closing this PR in favor of an issue. The fix is trivial (removes the _is_kimi_coding guard in build_anthropic_kwargs that was incorrectly blocking thinking for all Kimi endpoints) but has been pending review since June 19. See issue for details.

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 P2 Medium — degraded but workaround exists provider/kimi Kimi / Moonshot type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants