enchancements

This commit is contained in:
Vitali sharp8n 2026-09-14 17:27:38 +03:00
parent 833fffe722
commit 9d6f5dc22d
3 changed files with 22 additions and 1 deletions

View file

@ -124,6 +124,10 @@ public partial class RoutingService
var msg = RoleDialogModel.From(message,
role: AgentRole.Function,
content: message.Content);
// Preserve images produced by the tool (e.g. `browser_act screenshot`) so the next
// LLM round in this turn can attach them to the tool message for a multimodal model.
// They are not persisted (ConversationStorage ignores dialog.Files).
msg.Files = message.Files;
dialogs.Add(msg);
Context.AddDialogs([msg]);

View file

@ -66,6 +66,9 @@ public partial class RoutingService
message.RichContent = clonedMessage.RichContent;
message.Data = clonedMessage.Data;
message.MessageLabel = clonedMessage.MessageLabel;
// Tools may return images (e.g. a browser screenshot). Carry them back from the clone so
// the function dialog handed to the LLM can include the tool-produced image content.
message.Files = clonedMessage.Files;
}
catch (JsonException ex)
{

View file

@ -524,7 +524,21 @@ public class ChatCompletionProvider : IChatCompletion
messages.Add(assistantToolMsg);
messages.Add(new ToolChatMessage(message.ToolCallId.IfNullOrEmptyAs(message.FunctionName), message.LlmContent));
// A tool may produce images (e.g. `browser_act screenshot`): attach them to the tool
// message so a multimodal model can SEE the tool output instead of only reading the
// file name. Text-only models keep the plain text result. The gateway accepts image
// parts on a `tool` message; these files are transient (never persisted in history).
var toolContentParts = new List<ChatMessageContentPart>
{
ChatMessageContentPart.CreateTextPart(message.LlmContent)
};
if (allowMultiModal && !message.Files.IsNullOrEmpty())
{
CollectMessageContentParts(toolContentParts, message.Files, imageDetailLevel);
}
messages.Add(new ToolChatMessage(
message.ToolCallId.IfNullOrEmptyAs(message.FunctionName), toolContentParts));
}
else if (message.Role == AgentRole.User)
{