Skip to content

fix: drop thinking blocks for kimi provider to prevent crashes#39850

Open
GazeKingNuWu wants to merge 1 commit intoopenclaw:mainfrom
GazeKingNuWu:fix/kimi-crash
Open

fix: drop thinking blocks for kimi provider to prevent crashes#39850
GazeKingNuWu wants to merge 1 commit intoopenclaw:mainfrom
GazeKingNuWu:fix/kimi-crash

Conversation

@GazeKingNuWu
Copy link
Copy Markdown
Contributor

Summary

Fixes #39798 - kimi-coding/k2p5 crashes on turn 2+

Problem

kimi-coding uses modelApi: "anthropic-messages" but cannot handle the returned thinking signatures.

Fix

Add kimi provider to dropThinkingBlocks check.


AI-assisted PR

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: XS labels Mar 8, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 8, 2026

Greptile Summary

This PR attempts to fix crashes on turn 2+ for the kimi-coding provider (k2p5) by adding it to the dropThinkingBlocks guard in resolveTranscriptPolicy. However, the two provider IDs added — "kimi" and "kimi-api" — are incorrect and will never match the crashing provider.

  • "kimi" is the web-search provider (Moonshot/Kimi search, used under tools.web.search.provider). It is a different concept and is never passed as the model provider to resolveTranscriptPolicy.
  • "kimi-api" does not exist as a registered provider anywhere else in the codebase.
  • The actual crashing model provider, after normalization via normalizeProviderId, is "kimi-coding" (both the user-facing "kimi-coding" string and the legacy alias "kimi-code" resolve to this). This ID is absent from the new check, so the fix has no effect and the original crash remains.

Confidence Score: 0/5

  • The fix targets the wrong provider IDs and will not resolve the reported crash for kimi-coding/k2p5.
  • The core logic error means the intended fix never triggers: provider === "kimi" matches the unrelated web-search provider and provider === "kimi-api" matches nothing in the codebase, while the actual crashing provider "kimi-coding" is not checked. The PR will merge without fixing issue [Bug]: kimi-coding/k2p5 crashes on turn 2+ since v2026.3.7 (preserveSignatures regression) #39798.
  • src/agents/transcript-policy.ts line 104 — the dropThinkingBlocks condition must use "kimi-coding" instead of "kimi" and "kimi-api".

Last reviewed commit: 5858c34

const dropThinkingBlocks = isCopilotClaude;
// Also drop for kimi-coding which uses anthropic-messages API but cannot handle
// the returned thinking signatures (causes JSON parse errors in SDK).
const dropThinkingBlocks = isCopilotClaude || provider === "kimi" || provider === "kimi-api";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wrong provider IDs — fix won't apply to kimi-coding

The intent is to drop thinking blocks for the kimi-coding AI provider (model k2p5), but the two IDs added here don't match the provider that causes the crash:

  • "kimi" — this is the web search provider (Moonshot/Kimi search API configured under tools.web.search.provider). It is a completely separate concept from the AI model provider and is never passed to resolveTranscriptPolicy in this context.
  • "kimi-api" — this string does not appear anywhere else in the codebase as a registered provider ID.

The actual AI coding model provider, after going through normalizeProviderId on line 83, resolves to "kimi-coding" (both "kimi-coding" and the legacy alias "kimi-code" normalize to "kimi-coding" per model-selection.ts). The fix therefore never fires for the crashing provider, leaving the original bug unfixed.

The condition should be:

Suggested change
const dropThinkingBlocks = isCopilotClaude || provider === "kimi" || provider === "kimi-api";
const dropThinkingBlocks = isCopilotClaude || provider === "kimi-coding";
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/transcript-policy.ts
Line: 104

Comment:
**Wrong provider IDs — fix won't apply to kimi-coding**

The intent is to drop thinking blocks for the kimi-coding AI provider (model `k2p5`), but the two IDs added here don't match the provider that causes the crash:

- **`"kimi"`** — this is the *web search* provider (Moonshot/Kimi search API configured under `tools.web.search.provider`). It is a completely separate concept from the AI model provider and is never passed to `resolveTranscriptPolicy` in this context.
- **`"kimi-api"`** — this string does not appear anywhere else in the codebase as a registered provider ID.

The actual AI coding model provider, after going through `normalizeProviderId` on line 83, resolves to `"kimi-coding"` (both `"kimi-coding"` and the legacy alias `"kimi-code"` normalize to `"kimi-coding"` per `model-selection.ts`). The fix therefore never fires for the crashing provider, leaving the original bug unfixed.

The condition should be:
```suggestion
  const dropThinkingBlocks = isCopilotClaude || provider === "kimi-coding";
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 5858c341b4

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

const dropThinkingBlocks = isCopilotClaude;
// Also drop for kimi-coding which uses anthropic-messages API but cannot handle
// the returned thinking signatures (causes JSON parse errors in SDK).
const dropThinkingBlocks = isCopilotClaude || provider === "kimi" || provider === "kimi-api";
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 Match Kimi Coding provider ID when dropping thinking blocks

This condition does not include the actual model provider ID used for Kimi Code (kimi-coding), so the new workaround never activates for kimi-coding/k2p5 sessions and the turn-2+ crash remains reproducible. resolveTranscriptPolicy normalizes provider names and the rest of the codebase registers this provider as kimi-coding (with only kimi-code aliasing to it), so checking provider === "kimi" || provider === "kimi-api" misses the intended path.

Useful? React with 👍 / 👎.

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

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: kimi-coding/k2p5 crashes on turn 2+ since v2026.3.7 (preserveSignatures regression)

1 participant