fix: parse kimi tagged tool calls#60051
Conversation
Greptile SummaryThis PR fixes Kimi's tagged tool-call markup not being dispatched as structured tool calls by adding a stream-wrapper layer ( Key observations:
Confidence Score: 4/5Safe to merge; the change is scoped to the Kimi provider plugin with no impact on core or other providers. The implementation is logically correct, cleanly uses the public wrapStreamFn seam, and has three passing tests. The only gaps are a missing test for multiple concurrent tool calls and an undocumented assumption that Kimi always emits tool-call markup as the sole content of a text block — both are P2 style concerns that don't affect correctness for the verified real-world usage. extensions/kimi-coding/stream.ts — the strict startsWith/endsWith guard warrants a clarifying comment. Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/kimi-coding/stream.ts
Line: 21-25
Comment:
**Silent pass-through when tool markup is mixed with preamble text**
`parseKimiTaggedToolCalls` requires the entire (trimmed) text block to begin with `<|tool_calls_section_begin|>` and end with `<|tool_calls_section_end|>`. If Kimi ever emits a response where the tool-call section is preceded by a short preamble (e.g. `"Alright, let me do that: <|tool_calls_section_begin|>...<|tool_calls_section_end|>"`), the text block won't match the strict start-check, `parseKimiTaggedToolCalls` returns `null`, and the raw markup is silently passed through as plain text — no tool call will fire.
If this strict match is intentional (Kimi always emits the section tags as the sole content of a text block), a brief comment documenting that assumption would make the invariant explicit and help future maintainers understand why a substring search isn't used instead.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/kimi-coding/stream.test.ts
Line: 29-114
Comment:
**Missing test for multiple tool calls in a single section**
The parser's inner `while` loop is designed to handle multiple `<|tool_call_begin|>...<|tool_call_end|>` blocks within one `<|tool_calls_section_begin|>...<|tool_calls_section_end|>` section, but no test exercises this path. A model response with two parallel tool calls (e.g. `read` + `write`) would exercise the cursor-advance logic on line 82 and the multi-push on line 117. Adding a case here would give confidence that the counter-suffix stripping and `id` uniqueness work correctly across multiple calls.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix: parse kimi tagged tool calls" | Re-trigger Greptile |
c7452d0 to
5516d5c
Compare
* fix: parse kimi tagged tool calls * fix: parse kimi tagged tool calls (openclaw#60051) * fix: parse kimi tagged tool calls (openclaw#60051)
* fix: parse kimi tagged tool calls * fix: parse kimi tagged tool calls (openclaw#60051) * fix: parse kimi tagged tool calls (openclaw#60051)
* fix: parse kimi tagged tool calls * fix: parse kimi tagged tool calls (openclaw#60051) * fix: parse kimi tagged tool calls (openclaw#60051)
* fix: parse kimi tagged tool calls * fix: parse kimi tagged tool calls (openclaw#60051) * fix: parse kimi tagged tool calls (openclaw#60051)
* fix: parse kimi tagged tool calls * fix: parse kimi tagged tool calls (openclaw#60051) * fix: parse kimi tagged tool calls (openclaw#60051)
* fix: parse kimi tagged tool calls * fix: parse kimi tagged tool calls (openclaw#60051) * fix: parse kimi tagged tool calls (openclaw#60051)
Summary
readinstead of echoing raw tool markup