feat: auto-describe MCP tool result images via VLM
When an MCP tool returns image content items, the agent engine now automatically generates text descriptions using the configured VLM model and appends them to the tool result message. This makes image content accessible to LLMs that receive tool results as text. Images are not passed directly to the LLM because Chat Completions API does not reliably support images in tool role messages across providers (tested: gpt-5.4 silently ignores them, Qwen3.5 processes them). Changes: - Add Images field to ToolResult for preserving base64 data URIs - Add extractContentAndImages() with MIME whitelist, size/count limits - Add ImageDescriberFunc injection to AgentEngine (no vlm package dep) - Add describeImages() with graceful error handling and ctx cancellation - Add VLM model injection in CreateAgentEngine (same pattern as SetAppConfig/SetSkillsManager) - Redact image base64 from Data map to prevent log/SSE exposure
This commit is contained in:
@@ -18,6 +18,7 @@ type ToolResult struct {
|
||||
Output string `json:"output"` // Human-readable output
|
||||
Data map[string]interface{} `json:"data,omitempty"` // Structured data for programmatic use
|
||||
Error string `json:"error,omitempty"` // Error message if execution failed
|
||||
Images []string `json:"images,omitempty"` // Base64 data URIs from tool (e.g. MCP image content)
|
||||
}
|
||||
|
||||
// ToolCall represents a single tool invocation within an agent step
|
||||
|
||||
Reference in New Issue
Block a user