mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-01 15:32:11 +08:00
fix(cli): prevent infinite loop on empty tool-calls (#7756)
When the model returns finish_reason "tool-calls" but emits zero tool call parts, the prompt loop spins indefinitely. Detect this degenerate case in the processor after the stream completes: if finish is "tool-calls" but no tool parts exist, convert finish to "stop" so the loop's exit checks terminate normally.
This commit is contained in:
@@ -443,6 +443,13 @@ export namespace SessionProcessor {
|
||||
})
|
||||
}
|
||||
}
|
||||
// kilocode_change start — guard empty tool-calls (#7756)
|
||||
const empty = input.assistantMessage.finish === "tool-calls" && !p.some((part) => part.type === "tool")
|
||||
if (empty) {
|
||||
log.warn("empty tool-calls", { messageID: input.assistantMessage.id })
|
||||
input.assistantMessage.finish = "stop"
|
||||
}
|
||||
// kilocode_change end
|
||||
input.assistantMessage.time.completed = Date.now()
|
||||
await Session.updateMessage(input.assistantMessage)
|
||||
if (needsCompaction) return "compact"
|
||||
|
||||
Reference in New Issue
Block a user