fix: drop thinking blocks for kimi provider to prevent crashes#39850
fix: drop thinking blocks for kimi provider to prevent crashes#39850GazeKingNuWu wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR attempts to fix crashes on turn 2+ for the kimi-coding provider (
Confidence Score: 0/5
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"; |
There was a problem hiding this 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 undertools.web.search.provider). It is a completely separate concept from the AI model provider and is never passed toresolveTranscriptPolicyin 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:
| 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.There was a problem hiding this comment.
💡 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"; |
There was a problem hiding this comment.
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 👍 / 👎.
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
dropThinkingBlockscheck.AI-assisted PR