Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Enable structured AI auto-recovery paths

rcourtman21fa343fa16a
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 065c825676..e3f9745b20 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -241,6 +241,10 @@ resource that lacks that native log path, the shared tool boundary must fail
as a structured blocked response with a governed recovery hint toward the
correct shared path, such as `pulse_query action=get` for API-backed read-only
resources or `target_host` plus `container` for agent-routed app logs.
+When that recovery path is safe to execute deterministically, the blocked
+response should also carry a structured recovery tool call so the shared
+agentic loop can retry through the correct shared tool and arguments instead
+of assuming every recovery is a `command` rewrite on the original tool.
That same VMware AI rule also now includes mention resolution. Frontend
Assistant mention payloads for VMware-backed `agent`, `vm`, `storage`, and
canonical `app-container` resources must preserve the shared unified resource
diff --git a/internal/ai/chat/agentic.go b/internal/ai/chat/agentic.go
index b8a8276624..0f22516bfc 100644
--- a/internal/ai/chat/agentic.go
+++ b/internal/ai/chat/agentic.go
@@ -1283,34 +1283,26 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, me
Msg("[AgenticLoop] Tracking pending recovery for strict resolution block")
}
- // === AUTO-RECOVERY FOR NONINTERACTIVEONLY BLOCKS ===
- // If tool blocked with auto_recoverable=true and has a suggested_rewrite,
- // automatically apply the rewrite and retry once.
+ // === AUTO-RECOVERY FOR STRUCTURED BLOCKS ===
+ // If a tool returns a blocked response with auto_recoverable=true and a
+ // governed recovery plan, automatically apply that plan and retry once.
// Note: err == nil means executor didn't throw, isError means the tool result indicates error/block
if err == nil && isError && strings.Contains(resultText, `"auto_recoverable":true`) {
// Result is a blocked response (not a hard error)
- if suggestedRewrite, recoveryAttempted := tryAutoRecovery(result, tc, a.executor, ctx); suggestedRewrite != "" && !recoveryAttempted {
+ if recoveryPlan, recoveryAttempted := tryAutoRecovery(result, tc, a.executor, ctx); recoveryPlan != nil && !recoveryAttempted {
// This is a fresh recoverable block - attempt auto-recovery
log.Info().
Str("tool", tc.Name).
- Str("original_command", getCommandFromInput(tc.Input)).
- Str("suggested_rewrite", suggestedRewrite).
- Msg("[AgenticLoop] Attempting auto-recovery with suggested rewrite")
+ Str("recovery_tool", recoveryPlan.ToolName).
+ Interface("recovery_input", recoveryPlan.Input).
+ Msg("[AgenticLoop] Attempting structured auto-recovery")
// Record auto-recovery attempt
if metrics := GetAIMetrics(); metrics != nil {
- metrics.RecordAutoRecoveryAttempt("READ_ONLY_VIOLATION", tc.Name)
+ metrics.RecordAutoRecoveryAttempt(recoveryPlan.ErrorCode, tc.Name)
}
- // Apply the rewrite and retry
- modifiedInput := make(map[string]interface{})
- for k, v := range tc.Input {
- modifiedInput[k] = v
- }
- modifiedInput["command"] = suggestedRewrite
- modifiedInput["_auto_recovery_attempt"] = true // Prevent infinite loops
-
- retryResult, retryErr := a.executeToolSafely(ctx, tc.Name, modifiedInput)
+ retryResult, retryErr := a.executeToolSafely(ctx, recoveryPlan.ToolName, recoveryPlan.Input)
if retryErr != nil {
log.Warn().
Err(retryErr).
@@ -1322,7 +1314,7 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, me
Str("tool", tc.Name).
Msg("[AgenticLoop] Auto-recovery succeeded")
if metrics := GetAIMetrics(); metrics != nil {
- metrics.RecordAutoRecoverySuccess("READ_ONLY_VIOLATION", tc.Name)
+ metrics.RecordAutoRecoverySuccess(recoveryPlan.ErrorCode, tc.Name)
}
// Use the successful result
result = retryResult
@@ -1334,7 +1326,7 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, me
Str("retry_error", FormatToolResult(retryResult)).
Msg("[AgenticLoop] Auto-recovery retry still blocked")
// Keep original error but note the failed recovery attempt
- resultText = resultText + "\n\n[Auto-recovery attempted but failed. Please use the suggested command manually or switch to pulse_control.]"
+ resultText = resultText + "\n\n[Auto-recovery attempted but failed. Follow the recovery hint manually.]"
}
}
}
diff --git a/internal/ai/chat/agentic_additional_test.go b/internal/ai/chat/agentic_additional_test.go
index 2b25ca9c1d..81c34760a8 100644
--- a/internal/ai/chat/agentic_additional_test.go
+++ b/internal/ai/chat/agentic_additional_test.go
@@ -393,25 +393,49 @@ func TestAgenticLoop_DoesNotRetryErrorEventAfterVisibleOutput(t *testing.T) {
func TestTryAutoRecoveryAndCommandExtraction(t *testing.T) {
result := tools.CallToolResult{
- Content: []tools.Content{{Type: "text", Text: `{"error":{"details":{"auto_recoverable":true,"suggested_rewrite":"pulse_query action=get","category":"strict"}}}`}},
+ Content: []tools.Content{{Type: "text", Text: `{"error":{"code":"READ_ONLY_VIOLATION","details":{"auto_recoverable":true,"suggested_rewrite":"uptime","category":"strict"}}}`}},
IsError: true,
}
- rewrite, attempted := tryAutoRecovery(result, providers.ToolCall{Input: map[string]interface{}{}}, nil, context.Background())
- if attempted || rewrite == "" {
- t.Fatalf("expected suggested rewrite and no prior attempt")
+ plan, attempted := tryAutoRecovery(result, providers.ToolCall{
+ Name: "pulse_read",
+ Input: map[string]interface{}{"action": "exec"},
+ }, nil, context.Background())
+ if attempted || plan == nil {
+ t.Fatalf("expected recovery plan and no prior attempt")
+ }
+ if plan.ToolName != "pulse_read" || plan.Input["command"] != "uptime" {
+ t.Fatalf("unexpected legacy recovery plan: %+v", plan)
+ }
+ if plan.ErrorCode != "READ_ONLY_VIOLATION" {
+ t.Fatalf("expected READ_ONLY_VIOLATION error code, got %+v", plan)
}
- alt := tools.CallToolResult{
- Content: []tools.Content{{Type: "text", Text: `{"error":5,"auto_recoverable":true,"suggested_rewrite":"pulse_query action=list"}`}},
+ structured := tools.CallToolResult{
+ Content: []tools.Content{{Type: "text", Text: `{"error":{"code":"ACTION_NOT_ALLOWED","details":{"auto_recoverable":true,"suggested_tool":"pulse_query","suggested_arguments":{"action":"get","resource_type":"vm","resource_id":"app-01"}}}}`}},
IsError: true,
}
- rewrite, _ = tryAutoRecovery(alt, providers.ToolCall{Input: map[string]interface{}{}}, nil, context.Background())
- if rewrite == "" {
- t.Fatalf("expected suggested rewrite from alternate format")
+ plan, _ = tryAutoRecovery(structured, providers.ToolCall{Input: map[string]interface{}{}}, nil, context.Background())
+ if plan == nil {
+ t.Fatalf("expected structured recovery plan")
+ }
+ if plan.ToolName != "pulse_query" || plan.Input["action"] != "get" || plan.Input["resource_id"] != "app-01" {
+ t.Fatalf("unexpected structured recovery plan: %+v", plan)
+ }
+ if plan.ErrorCode != "ACTION_NOT_ALLOWED" {
+ t.Fatalf("expected ACTION_NOT_ALLOWED error code, got %+v", plan)
}
- rewrite, attempted = tryAutoRecovery(result, providers.ToolCall{Input: map[string]interface{}{"_auto_recovery_attempt": true}}, nil, context.Background())
- if !attempted || rewrite != "" {
+ retryTool := tools.CallToolResult{
+ Content: []tools.Content{{Type: "text", Text: `{"error":5,"auto_recoverable":true,"suggested_tool":"pulse_query","suggested_arguments":{"action":"list"}}`}},
+ IsError: true,
+ }
+ plan, _ = tryAutoRecovery(retryTool, providers.ToolCall{Input: map[string]interface{}{}}, nil, context.Background())
+ if plan == nil || plan.ToolName != "pulse_query" || plan.Input["action"] != "list" {
+ t.Fatalf("expected alternate-format structured recovery plan, got %+v", plan)
+ }
+
+ plan, attempted = tryAutoRecovery(result, providers.ToolCall{Input: map[string]interface{}{"_auto_recovery_attempt": true}}, nil, context.Background())
+ if !attempted || plan != nil {
t.Fatalf("expected auto recovery to be skipped when already attempted")
}
@@ -422,3 +446,111 @@ func TestTryAutoRecoveryAndCommandExtraction(t *testing.T) {
t.Fatalf("expected fallback command string")
}
}
+
+func TestAgenticLoop_AutoRecoveryExecutesStructuredToolCall(t *testing.T) {
+ executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{})
+ failCalls := 0
+ recoveryCalls := 0
+
+ executor.RegisterTool(tools.RegisteredTool{
+ Definition: tools.Tool{
+ Name: "fail_tool",
+ InputSchema: tools.InputSchema{
+ Type: "object",
+ Properties: map[string]tools.PropertySchema{},
+ },
+ },
+ Handler: func(ctx context.Context, exec *tools.PulseToolExecutor, args map[string]interface{}) (tools.CallToolResult, error) {
+ failCalls++
+ return tools.NewToolResponseResult(tools.NewToolBlockedError(
+ tools.ErrCodeActionNotAllowed,
+ "blocked",
+ map[string]interface{}{
+ "auto_recoverable": true,
+ "suggested_tool": "recovery_tool",
+ "suggested_arguments": map[string]interface{}{
+ "value": "recovered through query",
+ },
+ },
+ )), nil
+ },
+ })
+ executor.RegisterTool(tools.RegisteredTool{
+ Definition: tools.Tool{
+ Name: "recovery_tool",
+ InputSchema: tools.InputSchema{
+ Type: "object",
+ Properties: map[string]tools.PropertySchema{
+ "value": {Type: "string"},
+ },
+ },
+ },
+ Handler: func(ctx context.Context, exec *tools.PulseToolExecutor, args map[string]interface{}) (tools.CallToolResult, error) {
+ recoveryCalls++
+ value, _ := args["value"].(string)
+ return tools.NewTextResult(value), nil
+ },
+ })
+
+ provider := &stubStreamingProvider{}
+ loop := NewAgenticLoop(provider, executor, "prompt")
+ callCount := 0
+ provider.chatStream = func(ctx context.Context, req providers.ChatRequest, callback providers.StreamCallback) error {
+ callCount++
+ switch callCount {
+ case 1:
+ callback(providers.StreamEvent{
+ Type: "tool_start",
+ Data: providers.ToolStartEvent{ID: "call_1", Name: "fail_tool"},
+ })
+ callback(providers.StreamEvent{
+ Type: "done",
+ Data: providers.DoneEvent{
+ ToolCalls: []providers.ToolCall{{
+ ID: "call_1",
+ Name: "fail_tool",
+ Input: map[string]interface{}{},
+ }},
+ },
+ })
+ case 2:
+ if len(req.Messages) != 3 {
+ t.Fatalf("expected assistant tool call plus tool result, got %d messages", len(req.Messages))
+ }
+ if req.Messages[2].ToolResult == nil || req.Messages[2].ToolResult.IsError {
+ t.Fatalf("expected recovered tool result, got %+v", req.Messages[2].ToolResult)
+ }
+ if !strings.Contains(req.Messages[2].ToolResult.Content, "recovered through query") {
+ t.Fatalf("expected recovered output in provider follow-up, got %+v", req.Messages[2].ToolResult)
+ }
+ callback(providers.StreamEvent{
+ Type: "content",
+ Data: providers.ContentEvent{Text: "Recovered."},
+ })
+ callback(providers.StreamEvent{
+ Type: "done",
+ Data: providers.DoneEvent{},
+ })
+ default:
+ t.Fatalf("unexpected provider call %d", callCount)
+ }
+ return nil
+ }
+
+ results, err := loop.Execute(context.Background(), "structured-auto-recovery", []Message{{Role: "user", Content: "help"}}, func(event StreamEvent) {})
+ if err != nil {
+ t.Fatalf("expected successful auto-recovery, got %v", err)
+ }
+ if failCalls != 1 || recoveryCalls != 1 {
+ t.Fatalf("expected one fail call and one recovery call, got fail=%d recovery=%d", failCalls, recoveryCalls)
+ }
+ if len(results) != 3 {
+ t.Fatalf("expected assistant tool call, recovered tool result, and final response, got %+v", results)
+ }
+ if results[1].ToolResult == nil || !strings.Contains(results[1].ToolResult.Content, "recovered through query") {
+ t.Fatalf("expected recovered tool result in transcript, got %+v", results[1])
+ }
+ if results[2].Content != "Recovered." {
+ t.Fatalf("unexpected final response: %+v", results[2])
+ }
+}
diff --git a/internal/ai/chat/agentic_recovery.go b/internal/ai/chat/agentic_recovery.go
index fa1a62d1fc..249c12c263 100644
--- a/internal/ai/chat/agentic_recovery.go
+++ b/internal/ai/chat/agentic_recovery.go
@@ -9,14 +9,27 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/ai/tools"
)
-// tryAutoRecovery checks if a tool result is auto-recoverable and returns the suggested rewrite.
-// Returns (suggestedRewrite, alreadyAttempted) where:
-// - suggestedRewrite is the command to retry with (empty if not recoverable)
+type autoRecoveryPlan struct {
+ ErrorCode string
+ ToolName string
+ Input map[string]interface{}
+}
+
+type autoRecoveryDetails struct {
+ AutoRecoverable bool `json:"auto_recoverable"`
+ SuggestedRewrite string `json:"suggested_rewrite"`
+ SuggestedTool string `json:"suggested_tool"`
+ SuggestedArgument map[string]interface{} `json:"suggested_arguments"`
+}
+
+// tryAutoRecovery checks if a tool result is auto-recoverable and returns a retry plan.
+// Returns (plan, alreadyAttempted) where:
+// - plan is nil when no auto-recovery should be attempted
// - alreadyAttempted is true if auto-recovery was already attempted for this call
-func tryAutoRecovery(result tools.CallToolResult, tc providers.ToolCall, executor *tools.PulseToolExecutor, ctx context.Context) (string, bool) {
+func tryAutoRecovery(result tools.CallToolResult, tc providers.ToolCall, executor *tools.PulseToolExecutor, ctx context.Context) (*autoRecoveryPlan, bool) {
// Check if this is already a recovery attempt
if _, ok := tc.Input["_auto_recovery_attempt"]; ok {
- return "", true // Already attempted, don't retry again
+ return nil, true // Already attempted, don't retry again
}
// Parse the result to check for auto_recoverable flag
@@ -25,44 +38,114 @@ func tryAutoRecovery(result tools.CallToolResult, tc providers.ToolCall, executo
// Look for the structured error response pattern
// The result should contain JSON with auto_recoverable and suggested_rewrite
if !strings.Contains(resultStr, `"auto_recoverable"`) {
- return "", false
+ return nil, false
}
// Extract the JSON portion from the result
// Results are formatted as "Error: {json}" or just "{json}"
jsonStart := strings.Index(resultStr, "{")
if jsonStart == -1 {
- return "", false
+ return nil, false
}
var parsed struct {
Error struct {
+ Code string `json:"code"`
Details struct {
- AutoRecoverable bool `json:"auto_recoverable"`
- SuggestedRewrite string `json:"suggested_rewrite"`
- Category string `json:"category"`
+ AutoRecoverable bool `json:"auto_recoverable"`
+ SuggestedRewrite string `json:"suggested_rewrite"`
+ SuggestedTool string `json:"suggested_tool"`
+ SuggestedArgument map[string]interface{} `json:"suggested_arguments"`
+ Category string `json:"category"`
} `json:"details"`
} `json:"error"`
+ AutoRecoverable bool `json:"auto_recoverable"`
+ SuggestedRewrite string `json:"suggested_rewrite"`
+ SuggestedTool string `json:"suggested_tool"`
+ SuggestedArgument map[string]interface{} `json:"suggested_arguments"`
}
if err := json.Unmarshal([]byte(resultStr[jsonStart:]), &parsed); err != nil {
// Try alternative format where details are at top level
var altParsed struct {
- AutoRecoverable bool `json:"auto_recoverable"`
- SuggestedRewrite string `json:"suggested_rewrite"`
+ ErrorCode string `json:"error_code"`
+ AutoRecoverable bool `json:"auto_recoverable"`
+ SuggestedRewrite string `json:"suggested_rewrite"`
+ SuggestedTool string `json:"suggested_tool"`
+ SuggestedArguments map[string]interface{} `json:"suggested_arguments"`
}
if err2 := json.Unmarshal([]byte(resultStr[jsonStart:]), &altParsed); err2 != nil {
- return "", false
+ return nil, false
+ }
+ return buildAutoRecoveryPlan(tc, altParsed.ErrorCode, autoRecoveryDetails{
+ AutoRecoverable: altParsed.AutoRecoverable,
+ SuggestedRewrite: altParsed.SuggestedRewrite,
+ SuggestedTool: altParsed.SuggestedTool,
+ SuggestedArgument: altParsed.SuggestedArguments,
+ }), false
+ }
+
+ if plan := buildAutoRecoveryPlan(tc, parsed.Error.Code, autoRecoveryDetails{
+ AutoRecoverable: parsed.Error.Details.AutoRecoverable,
+ SuggestedRewrite: parsed.Error.Details.SuggestedRewrite,
+ SuggestedTool: parsed.Error.Details.SuggestedTool,
+ SuggestedArgument: parsed.Error.Details.SuggestedArgument,
+ }); plan != nil {
+ return plan, false
+ }
+
+ return buildAutoRecoveryPlan(tc, parsed.Error.Code, autoRecoveryDetails{
+ AutoRecoverable: parsed.AutoRecoverable,
+ SuggestedRewrite: parsed.SuggestedRewrite,
+ SuggestedTool: parsed.SuggestedTool,
+ SuggestedArgument: parsed.SuggestedArgument,
+ }), false
+}
+
+func buildAutoRecoveryPlan(tc providers.ToolCall, errorCode string, details autoRecoveryDetails) *autoRecoveryPlan {
+ if !details.AutoRecoverable {
+ return nil
+ }
+
+ if suggestedTool := strings.TrimSpace(details.SuggestedTool); suggestedTool != "" {
+ input := cloneAutoRecoveryInput(details.SuggestedArgument)
+ input["_auto_recovery_attempt"] = true
+ return &autoRecoveryPlan{
+ ErrorCode: firstNonEmptyAutoRecoveryCode(errorCode),
+ ToolName: suggestedTool,
+ Input: input,
}
- if altParsed.AutoRecoverable && altParsed.SuggestedRewrite != "" {
- return altParsed.SuggestedRewrite, false
+ }
+
+ if suggestedRewrite := strings.TrimSpace(details.SuggestedRewrite); suggestedRewrite != "" {
+ input := cloneAutoRecoveryInput(tc.Input)
+ input["command"] = suggestedRewrite
+ input["_auto_recovery_attempt"] = true
+ return &autoRecoveryPlan{
+ ErrorCode: firstNonEmptyAutoRecoveryCode(errorCode),
+ ToolName: tc.Name,
+ Input: input,
}
- return "", false
}
- if parsed.Error.Details.AutoRecoverable && parsed.Error.Details.SuggestedRewrite != "" {
- return parsed.Error.Details.SuggestedRewrite, false
+ return nil
+}
+
+func cloneAutoRecoveryInput(input map[string]interface{}) map[string]interface{} {
+ if len(input) == 0 {
+ return map[string]interface{}{}
+ }
+ cloned := make(map[string]interface{}, len(input)+1)
+ for key, value := range input {
+ cloned[key] = value
}
+ return cloned
+}
- return "", false
+func firstNonEmptyAutoRecoveryCode(code string) string {
+ code = strings.TrimSpace(code)
+ if code == "" {
+ return "AUTO_RECOVERY"
+ }
+ return code
}
diff --git a/internal/ai/tools/tools_read.go b/internal/ai/tools/tools_read.go
index 0f6645d273..6e7bdae9e3 100644
--- a/internal/ai/tools/tools_read.go
+++ b/internal/ai/tools/tools_read.go
@@ -478,10 +478,10 @@ func (e *PulseToolExecutor) executeNativeAppContainerReadLogs(ctx context.Contex
resolved := validation.Resource
if resolved.GetKind() != "app-container" {
- return blockedNativeReadLogsResult(resolved, resourceRef, container), nil
+ return blockedNativeReadLogsResult(resolved, resourceRef, container, lines), nil
}
if !strings.EqualFold(strings.TrimSpace(resolved.GetAdapter()), "truenas") {
- return blockedNativeReadLogsResult(resolved, resourceRef, container), nil
+ return blockedNativeReadLogsResult(resolved, resourceRef, container, lines), nil
}
if e.appContainerReadProvider == nil {
return NewErrorResult(fmt.Errorf("native app-container read provider is not available")), nil
@@ -525,7 +525,7 @@ func (e *PulseToolExecutor) executeNativeAppContainerReadLogs(ctx context.Contex
return NewTextResult(fmt.Sprintf("%s:\n%s", title, output)), nil
}
-func blockedNativeReadLogsResult(resolved ResolvedResourceInfo, resourceRef, container string) CallToolResult {
+func blockedNativeReadLogsResult(resolved ResolvedResourceInfo, resourceRef, container string, lines int) CallToolResult {
resourceRef = strings.TrimSpace(resourceRef)
if resolved == nil {
return NewErrorResult(fmt.Errorf("resource '%s' does not support native logs through pulse_read", resourceRef))
@@ -557,8 +557,19 @@ func blockedNativeReadLogsResult(resolved ResolvedResourceInfo, resourceRef, con
containerName = resourceName
}
if targetHost != "" {
+ suggestedArgs := map[string]interface{}{
+ "action": "logs",
+ "target_host": targetHost,
+ "container": containerName,
+ }
+ if lines > 0 {
+ suggestedArgs["lines"] = lines
+ }
details["target_host"] = targetHost
details["container"] = containerName
+ details["auto_recoverable"] = true
+ details["suggested_tool"] = "pulse_read"
+ details["suggested_arguments"] = suggestedArgs
details["recovery_hint"] = fmt.Sprintf(
"Use pulse_read action=logs target_host=%q container=%q for app logs on this platform.",
targetHost,
@@ -580,6 +591,14 @@ func blockedNativeReadLogsResult(resolved ResolvedResourceInfo, resourceRef, con
if queryResourceID == "" {
queryResourceID = resourceRef
}
+ suggestedArgs := map[string]interface{}{
+ "action": "get",
+ "resource_type": queryType,
+ "resource_id": queryResourceID,
+ }
+ details["auto_recoverable"] = true
+ details["suggested_tool"] = "pulse_query"
+ details["suggested_arguments"] = suggestedArgs
details["recovery_hint"] = fmt.Sprintf(
"Use pulse_query action=get resource_type=%q resource_id=%q to inspect status, alerts, activity, and metrics for this resource.",
queryType,
diff --git a/internal/ai/tools/tools_read_test.go b/internal/ai/tools/tools_read_test.go
index eaa381c25c..d33faaedfa 100644
--- a/internal/ai/tools/tools_read_test.go
+++ b/internal/ai/tools/tools_read_test.go
@@ -277,11 +277,18 @@ func TestExecuteReadLogs_VMwareResourcesReturnStructuredQueryGuidance(t *testing
assert.Contains(t, payload.Error.Message, "does not expose native logs through pulse_read")
assert.Equal(t, tc.wantKind, payload.Error.Details["resource_type"])
assert.Equal(t, "vmware-vsphere", payload.Error.Details["adapter"])
+ assert.Equal(t, true, payload.Error.Details["auto_recoverable"])
+ assert.Equal(t, "pulse_query", payload.Error.Details["suggested_tool"])
hint, ok := payload.Error.Details["recovery_hint"].(string)
require.True(t, ok)
assert.Contains(t, hint, `pulse_query action=get`)
assert.Contains(t, hint, `resource_type="`+tc.wantKind+`"`)
+
+ suggestedArgs, ok := payload.Error.Details["suggested_arguments"].(map[string]interface{})
+ require.True(t, ok)
+ assert.Equal(t, "get", suggestedArgs["action"])
+ assert.Equal(t, tc.wantKind, suggestedArgs["resource_type"])
})
}
}
@@ -322,11 +329,19 @@ func TestExecuteReadLogs_NonNativeAppContainersReturnStructuredTargetHostGuidanc
assert.Equal(t, "app-container", payload.Error.Details["resource_type"])
assert.Equal(t, "docker-host", payload.Error.Details["target_host"])
assert.Equal(t, "homepage", payload.Error.Details["container"])
+ assert.Equal(t, true, payload.Error.Details["auto_recoverable"])
+ assert.Equal(t, "pulse_read", payload.Error.Details["suggested_tool"])
hint, ok := payload.Error.Details["recovery_hint"].(string)
require.True(t, ok)
assert.Contains(t, hint, `target_host="docker-host"`)
assert.Contains(t, hint, `container="homepage"`)
+
+ suggestedArgs, ok := payload.Error.Details["suggested_arguments"].(map[string]interface{})
+ require.True(t, ok)
+ assert.Equal(t, "logs", suggestedArgs["action"])
+ assert.Equal(t, "docker-host", suggestedArgs["target_host"])
+ assert.Equal(t, "homepage", suggestedArgs["container"])
}
func decodeToolResponse(t *testing.T, result CallToolResult) ToolResponse {