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.

Give Assistant the current time so it stops deflecting time questions

rcourtman3465a3bbf451
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index abb28e691b..fee531439a 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -2278,6 +2278,17 @@ deriving an older display status from `workflowStatusHistory`.
## Current State
+The per-turn Assistant system prompt carries the current wall-clock time (the
+Pulse server clock) so the Assistant answers "what time/date is it" directly
+instead of deflecting ("I don't have access to a real-time clock") or demanding
+a `target_host` just to run `date`. The timestamp is appended in
+`AgenticLoop.getSystemPrompt` (`internal/ai/chat/agentic_prompt.go`) rather than
+baked into `baseSystemPrompt`: the base prompt is frozen when the loop is
+constructed at service start, so anything that must stay fresh per turn
+(execution mode, current time) is appended on each turn. The current time
+carries no PII and is therefore safe on cloud-routed turns regardless of the
+operational-context sharing opt-in.
+
Assistant slash-command availability is part of the command runtime contract,
not only visual polish. The OpenCode reference at fetched `origin/dev` commit
`c495635` filters prompt slash commands through the registered command catalog
diff --git a/internal/ai/chat/agentic_prompt.go b/internal/ai/chat/agentic_prompt.go
index 5cda92a251..0e5e06e0da 100644
--- a/internal/ai/chat/agentic_prompt.go
+++ b/internal/ai/chat/agentic_prompt.go
@@ -1,7 +1,15 @@
package chat
+import (
+ "fmt"
+ "time"
+)
+
// getSystemPrompt builds the full system prompt including the current mode context.
-// This is called at request time so the prompt reflects the current mode.
+// This is called at request time so the prompt reflects the current mode and the
+// current wall-clock time. The base prompt is frozen when the loop is created at
+// service start, so anything that must stay fresh per turn (mode, current time)
+// is appended here rather than baked into baseSystemPrompt.
func (a *AgenticLoop) getSystemPrompt() string {
a.mu.Lock()
isAutonomous := a.autonomousMode
@@ -22,7 +30,19 @@ user asks you to perform an action, choose the appropriate tool and Pulse will h
required approval prompt.`
}
- prompt := a.baseSystemPrompt + modeContext
+ // Give the model the current time directly. Without this the Assistant has no
+ // clock in context and deflects time/date questions ("I don't have access to a
+ // real-time clock", "tell me a target host and I'll run `date`") even in
+ // autonomous mode. The wall-clock value is the Pulse server clock and carries no
+ // PII, so it is safe to share with cloud-routed models. Formatted per turn so a
+ // long-lived session stays current rather than freezing at service-start time.
+ currentTime := fmt.Sprintf(`
+CURRENT TIME: %s (Pulse server clock).
+Treat this as the current date and time. Answer "what time is it" / "what's the date" style
+questions directly from this value — do not run a command or ask for a target host just to
+report the current time.`, time.Now().Format("Mon, 02 Jan 2006 15:04:05 MST"))
+
+ prompt := a.baseSystemPrompt + modeContext + currentTime
// Append accumulated knowledge facts to system prompt
if ka := a.knowledgeAccumulator; ka != nil && ka.Len() > 0 {
diff --git a/internal/ai/chat/agentic_test.go b/internal/ai/chat/agentic_test.go
index 7c745d6228..cee766991e 100644
--- a/internal/ai/chat/agentic_test.go
+++ b/internal/ai/chat/agentic_test.go
@@ -436,6 +436,30 @@ func TestAgenticLoop_UpdateTools(t *testing.T) {
assert.True(t, hasMetrics)
}
+func TestAgenticLoop_SystemPromptIncludesCurrentTime(t *testing.T) {
+ mockProvider := &MockProvider{}
+ executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{})
+ loop := NewAgenticLoop(mockProvider, executor, "BASE PROMPT BODY")
+
+ prompt := loop.getSystemPrompt()
+
+ // The base prompt must still be present...
+ if !strings.Contains(prompt, "BASE PROMPT BODY") {
+ t.Fatalf("expected base prompt to be preserved, got %q", prompt)
+ }
+ // ...alongside a fresh current-time block so the Assistant can answer
+ // time/date questions without a clock-less deflection or a target-host demand.
+ if !strings.Contains(prompt, "CURRENT TIME:") {
+ t.Fatalf("expected system prompt to carry CURRENT TIME, got %q", prompt)
+ }
+ if !strings.Contains(prompt, fmt.Sprintf("%d", time.Now().Year())) {
+ t.Fatalf("expected system prompt to carry the current year, got %q", prompt)
+ }
+ if !strings.Contains(prompt, "do not run a command or ask for a target host just to") {
+ t.Fatalf("expected system prompt to tell the model not to deflect time questions, got %q", prompt)
+ }
+}
+
func TestAgenticLoop_AnswerQuestion(t *testing.T) {
mockProvider := &MockProvider{}
executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{})