fix(tool): route binary outputs through the media pipeline.

This commit is contained in:
afjcjsbx
2026-03-22 12:05:28 +01:00
parent c0bb8d6df9
commit df4f322f09
14 changed files with 1462 additions and 64 deletions
+39
View File
@@ -3,6 +3,7 @@ package tools
import (
"encoding/json"
"errors"
"strings"
"testing"
)
@@ -227,3 +228,41 @@ func TestToolResultJSONStructure(t *testing.T) {
t.Errorf("Expected silent false, got %v", parsed["silent"])
}
}
func TestToolResultContentForLLM_AppendsHandledDeliveryNote(t *testing.T) {
result := MediaResult("Screenshot attached.", []string{"media://example"}).WithResponseHandled()
content := result.ContentForLLM()
if !strings.Contains(content, "Screenshot attached.") {
t.Fatalf("expected original content in ContentForLLM, got %q", content)
}
if !strings.Contains(content, handledToolLLMNote) {
t.Fatalf("expected handled delivery note in ContentForLLM, got %q", content)
}
}
func TestToolResultContentForLLM_UsesHandledDeliveryNoteWhenEmpty(t *testing.T) {
result := (&ToolResult{}).WithResponseHandled()
if got := result.ContentForLLM(); got != handledToolLLMNote {
t.Fatalf("ContentForLLM() = %q, want %q", got, handledToolLLMNote)
}
}
func TestToolResultContentForLLM_AppendsArtifactPaths(t *testing.T) {
result := &ToolResult{
ForLLM: "Artifact created.",
ArtifactTags: []string{"[file:/tmp/example.png]"},
}
content := result.ContentForLLM()
if !strings.Contains(content, "Artifact created.") {
t.Fatalf("expected original content in ContentForLLM, got %q", content)
}
if !strings.Contains(content, "Local artifact paths: [file:/tmp/example.png]") {
t.Fatalf("expected artifact path note in ContentForLLM, got %q", content)
}
if !strings.Contains(content, artifactPathsLLMNote) {
t.Fatalf("expected artifact guidance note in ContentForLLM, got %q", content)
}
}