Restore assistant bridge message insertion for compat flag

This commit is contained in:
Mario Zechner 2025-12-11 00:36:35 +01:00
parent b0628786a7
commit 078661c3b1

View file

@ -369,6 +369,15 @@ function convertMessages(
let lastRole: string | null = null;
for (const msg of transformedMessages) {
// Some providers (e.g. Mistral/Devstral) don't allow user messages directly after tool results
// Insert a synthetic assistant message to bridge the gap
if (compat.requiresAssistantAfterToolResult && lastRole === "toolResult" && msg.role === "user") {
params.push({
role: "assistant",
content: "I have processed the tool results.",
});
}
if (msg.role === "user") {
if (typeof msg.content === "string") {
params.push({