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.

Stop withholding tools from short resource lookups

rcourtman9573c6f625cb
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 5af42d6fbf..a458aacbb6 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -2358,6 +2358,18 @@ message) rather than `chat.isLoading()` so it persists for the whole turn:
`isLoading` flips false at visible-turn-complete, which previously made the dock
flash its status for a frame and vanish.
+Prompt length must not gate tool availability. `assistantPromptLooksConversational`
+(`internal/ai/chat/service.go`) classifies only explicit greeting/meta prompts
+("hi", "thanks", "who are you") as conversational/text-only; it must not withhold
+tools from a turn merely because the prompt is short. Short prompts are usually
+resource lookups ("hows esphome", "check frigate", "grafana cpu") that need the
+query/read/metrics tools to answer from Pulse data — withholding tools by word
+count made the Assistant tell the user it had "no infrastructure context or
+diagnostic tools" and ask them to run `docker ps` themselves, for a resource
+Pulse already inventories. Tool selection stays model-owned: offer the tools and
+let the model decide whether to use them, rather than pre-deciding from prompt
+keywords/length that no tools are needed.
+
When the model runs tools but returns no final narrative, the deterministic
fallback summary (`buildAutomaticFallbackSummary` in
`internal/ai/chat/agentic_final.go`) must read as a clean operator message, not a
diff --git a/internal/ai/chat/service.go b/internal/ai/chat/service.go
index 166f0c217f..5854edd5ad 100644
--- a/internal/ai/chat/service.go
+++ b/internal/ai/chat/service.go
@@ -4492,7 +4492,13 @@ func assistantPromptLooksConversational(normalized string) bool {
}) {
return true
}
- return len(strings.Fields(trimmed)) <= 3
+ // Do NOT treat a prompt as conversational just because it is short. Short
+ // prompts are usually resource lookups ("hows esphome", "check frigate",
+ // "grafana cpu") that NEED tools — withholding tools by word count made the
+ // Assistant tell the user it had no way to inspect their infrastructure.
+ // Only the explicit greeting/meta patterns above are conversational; let the
+ // model decide whether to actually use the tools it is offered.
+ return false
}
func assistantPromptContainsAny(normalized string, needles []string) bool {
diff --git a/internal/ai/chat/service_tooling_test.go b/internal/ai/chat/service_tooling_test.go
index f801cd4f6c..cd6fd94055 100644
--- a/internal/ai/chat/service_tooling_test.go
+++ b/internal/ai/chat/service_tooling_test.go
@@ -271,6 +271,38 @@ func TestToolsForAssistantTurn_AlertPromptsKeepFullManifest(t *testing.T) {
}
}
+func TestToolsForAssistantTurn_ShortResourceLookupGetsTools(t *testing.T) {
+ exec := tools.NewPulseToolExecutor(tools.ExecutorConfig{
+ StateProvider: fakeStateProvider{},
+ AgentServer: fakeAgentServer{},
+ ReadState: &fakeCanonicalReadState{},
+ ControlLevel: tools.ControlLevelControlled,
+ })
+ svc := &Service{executor: exec}
+
+ // Short prompts that name a resource are lookups, not chit-chat. They must be
+ // offered tools so the Assistant can inspect the resource from Pulse data
+ // instead of telling the user it has no way to check.
+ for _, prompt := range []string{"hows esphome", "check frigate", "grafana cpu", "esphome status"} {
+ toolsList := svc.toolsForAssistantTurn(prompt, false, false, false)
+ if len(toolsList) == 0 {
+ t.Fatalf("short resource lookup %q was offered no tools", prompt)
+ }
+ promptText := svc.buildSystemPromptForOfferedTools(toolsList)
+ if strings.Contains(promptText, "No Pulse tools are offered for this turn") {
+ t.Fatalf("short resource lookup %q got the text-only tool boundary, got %q", prompt, promptText)
+ }
+ }
+
+ // Explicit greetings / meta-questions remain text-only.
+ for _, prompt := range []string{"hi", "hello there", "thanks", "who are you"} {
+ toolsList := svc.toolsForAssistantTurn(prompt, false, false, false)
+ if len(toolsList) != 0 {
+ t.Fatalf("conversational prompt %q should be text-only, got %d tools", prompt, len(toolsList))
+ }
+ }
+}
+
func TestToolsForAssistantTurn_ModelHandoffKeepsFullManifest(t *testing.T) {
exec := tools.NewPulseToolExecutor(tools.ExecutorConfig{
StateProvider: fakeStateProvider{},