mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 21:03:56 +00:00
Restore assistant bridge message insertion for compat flag
This commit is contained in:
parent
b0628786a7
commit
078661c3b1
1 changed files with 9 additions and 0 deletions
|
|
@ -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({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue