Files
Pulse/internal/ai/chat/agentic_tool_display.go
rcourtman e37353f937 Remove inferred Assistant continuation gates
Let the configured model choose investigation steps within explicit budgets.
Keep canonical planning, permissions and independent verification authoritative,
and preserve streamed conclusions in conversation history.

Expose recorded action outcomes so cached inventory cannot stand in for an
approval or execution receipt. Retain full plan context and make the exact
action review reachable from Assistant, including on narrow screens.

Refs #1782
2026-09-07 14:06:58 +01:00

53 lines
1.6 KiB
Go

package chat
import (
"encoding/json"
"fmt"
"github.com/rcourtman/pulse-go-rewrite/internal/agentcapabilities"
)
func formatToolInputForFrontend(toolName string, input map[string]interface{}, emptyIfNil bool) (inputStr string, rawInput string) {
// Canonical exposure projection: every user-visible or durable view
// of tool-call arguments routes through here, so restricted values
// (proposal params) never leave the transient provider/validation
// path.
input = agentcapabilities.RedactToolCallArgumentsForExposure(toolName, input)
if input == nil {
if emptyIfNil {
return "", ""
}
return "{}", ""
}
if inputBytes, err := json.Marshal(input); err == nil {
rawInput = string(inputBytes)
}
if toolName == agentcapabilities.PulseControlToolName {
action, _ := input["action"].(string)
resource, _ := input["resource_id"].(string)
return fmt.Sprintf("Plan %s on %s", action, resource), rawInput
}
// Special handling for command execution tools to avoid showing raw JSON.
if toolName == agentcapabilities.PulseRunCommandToolName || toolName == "control" {
if cmd, ok := input["command"].(string); ok {
return fmt.Sprintf("Running: %s", cmd), rawInput
}
if action, ok := input["action"].(string); ok {
target := ""
if t, ok := input["guest_id"].(string); ok {
target = t
} else if t, ok := input["container"].(string); ok {
target = t
}
return fmt.Sprintf("%s %s", action, target), rawInput
}
}
if inputBytes, err := json.Marshal(input); err == nil {
return string(inputBytes), rawInput
}
return "{}", rawInput
}