feat(agent): add pretty_print and disable_escape_html options for tool feedback

- Add PrettyPrint and DisableEscapeHTML config options to ToolFeedbackConfig
- Add FormatArgsJSON helper function with configurable pretty printing and HTML escaping
- Add toolFeedbackArgsPreviewWithOptions to pass formatting options
- Update pipeline_execute.go to use new formatting options for tool feedback

This fixes the issue where '&&' would be displayed as '\u0026' in tool
feedback messages and provides optional pretty-printing for better
readability.
This commit is contained in:
David Siewert
2026-04-25 20:46:16 +06:00
parent 77be169db4
commit bcc3d447a1
5 changed files with 38 additions and 8 deletions
+17
View File
@@ -1,12 +1,29 @@
package utils
import (
"bytes"
"encoding/json"
"fmt"
"strings"
)
const ToolFeedbackContinuationHint = "Continuing the current task."
func FormatArgsJSON(args map[string]any, prettyPrint, disableEscapeHTML bool) string {
var buf bytes.Buffer
enc := json.NewEncoder(&buf)
if prettyPrint {
enc.SetIndent("", " ")
}
if disableEscapeHTML {
enc.SetEscapeHTML(false)
}
if err := enc.Encode(args); err != nil {
return "{}"
}
return strings.TrimSpace(buf.String())
}
// FormatToolFeedbackMessage renders a tool feedback message for chat channels.
// It keeps the tool name on the first line for animation and can include both
// a human explanation and the serialized tool arguments in the body.