Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thin-forks-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kilo-code": patch
---

Fix tool use failure for providers returning numeric tool call IDs (e.g. MiniMax) by coercing ID to string in the shared stream parser
6 changes: 5 additions & 1 deletion src/core/assistant-message/NativeToolCallParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ export class NativeToolCallParser {
arguments?: string
}): ToolCallStreamEvent[] {
const events: ToolCallStreamEvent[] = []
const { index, id, name, arguments: args } = chunk
// kilocode_change start: Some providers (e.g. MiniMax) return tool call id as a number; coerce to string.
const { index, id: rawId, name, arguments: args } = chunk

const id = rawId != null ? String(rawId) : undefined
// kilocode_change end

let tracked = this.rawChunkTracker.get(index)

Expand Down
47 changes: 47 additions & 0 deletions src/core/assistant-message/__tests__/NativeToolCallParser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,51 @@ describe("NativeToolCallParser", () => {
})
})
})

// kilocode_change start
describe("processRawChunk", () => {
it("should coerce numeric tool call id to string", () => {
const events = NativeToolCallParser.processRawChunk({
index: 0,
id: 42 as unknown as string,
name: "read_file",
arguments: '{"path":"test.ts"}',
})

expect(events).toHaveLength(2) // start + delta
expect(events[0]).toMatchObject({
type: "tool_call_start",
id: "42",
name: "read_file",
})
expect(typeof events[0].id).toBe("string")
})

it("should leave undefined id as undefined", () => {
const events = NativeToolCallParser.processRawChunk({
index: 0,
id: undefined,
name: "read_file",
})

// No id means no tracking is initialized, so no events emitted
expect(events).toHaveLength(0)
})

it("should pass through string id unchanged", () => {
const events = NativeToolCallParser.processRawChunk({
index: 0,
id: "call_abc123",
name: "read_file",
})

expect(events).toHaveLength(1)
expect(events[0]).toMatchObject({
type: "tool_call_start",
id: "call_abc123",
name: "read_file",
})
})
})
// kilocode_change end
})
Loading