Restore assistant bridge message insertion for compat flag
This commit is contained in:
@@ -369,6 +369,15 @@ function convertMessages(
|
|||||||
let lastRole: string | null = null;
|
let lastRole: string | null = null;
|
||||||
|
|
||||||
for (const msg of transformedMessages) {
|
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 (msg.role === "user") {
|
||||||
if (typeof msg.content === "string") {
|
if (typeof msg.content === "string") {
|
||||||
params.push({
|
params.push({
|
||||||
|
|||||||
Reference in New Issue
Block a user