fix: only keep aborted messages if they have sufficient parts (#2651)

This commit is contained in:
Aiden Cline
2025-09-17 14:24:53 -05:00
committed by GitHub
parent 733b21e22b
commit ff6a93f355

View File

@@ -281,9 +281,19 @@ export namespace SessionPrompt {
}),
),
...MessageV2.toModelMessage(
msgs.filter(
(m) => !(m.info.role === "assistant" && m.info.error && !MessageV2.AbortedError.isInstance(m.info.error)),
),
msgs.filter((m) => {
if (m.info.role !== "assistant" || m.info.error === undefined) {
return true
}
if (
MessageV2.AbortedError.isInstance(m.info.error) &&
m.parts.some((part) => part.type !== "step-start" && part.type !== "reasoning")
) {
return true
}
return false
}),
),
],
tools: model.info.tool_call === false ? undefined : tools,