fix(chat): enforce retrieved image output in answers
When retrieved context or tool results contain Markdown images, dynamically append output requirements to system prompts and final-answer instructions. Also normalize fullwidth image parentheses in the frontend renderer so localized model output still renders correctly.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFinalAnswerImageRequirement(t *testing.T) {
|
||||
if got := finalAnswerImageRequirement(false); got != "" {
|
||||
t.Fatalf("text-only tool results should not add an image requirement: %q", got)
|
||||
}
|
||||
|
||||
got := finalAnswerImageRequirement(true)
|
||||
for _, required := range []string{
|
||||
"MUST include at least one relevant Markdown image",
|
||||
"Preserve its complete URL exactly",
|
||||
"ASCII half-width parentheses",
|
||||
"silently verify",
|
||||
} {
|
||||
if !strings.Contains(got, required) {
|
||||
t.Fatalf("expected %q in final-answer image requirement:\n%s", required, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user