mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user