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:
wizardchen
2026-07-15 18:09:17 +08:00
committed by lyingbug
parent 951f95903b
commit fbc9db85d1
11 changed files with 264 additions and 5 deletions
+7
View File
@@ -424,6 +424,13 @@ func (e *AgentEngine) appendToolResults(
messages []chat.Message,
step types.AgentStep,
) []chat.Message {
if stepContainsMarkdownImage(step) {
// Keep the requirement at system priority even when a custom Agent prompt
// replaces the built-in template. Appending it once, when image-bearing
// evidence first appears, also avoids burdening text-only turns.
messages = appendAgentRetrievedImageRequirement(messages)
}
// Add assistant message with tool calls (if any)
if step.Thought != "" || len(step.ToolCalls) > 0 || step.ReasoningContent != "" {
assistantMsg := chat.Message{