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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Normalize subscription models before CLI execution
rcourtman61ef640a5190
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex b75fd32beb..af01586bbe 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -267,7 +267,11 @@ duplicate or empty call IDs, malformed argument objects, and violations ofcan execute anything. The normal registry, profile, approval, protectedresource, action, and verification contracts remain the only infrastructureauthority. Calls are serialized per local subscription agent and bounded by-the configured request timeout and prompt/output size limits.+the configured request timeout and prompt/output size limits. The native+provider boundary accepts the canonical qualified Pulse model identity from+shared callers, strips only its own subscription-provider prefix before CLI+execution, and rejects foreign provider prefixes rather than forwarding an+invalid or cross-provider model name to the local agent.Patrol consumes the provider streaming interface, so the adapter projects eachfully validated CLI turn into canonical buffered `content`, `tool_start`, and`done` events. It must emit nothing before the complete CLI response passes thediff --git a/internal/ai/providers/subscription_agent.go b/internal/ai/providers/subscription_agent.goindex 33e93ae746..7260dbedb6 100644--- a/internal/ai/providers/subscription_agent.go+++ b/internal/ai/providers/subscription_agent.go@@ -11,6 +11,8 @@ import ("path/filepath""strings""time"++ "github.com/rcourtman/pulse-go-rewrite/internal/config")// SubscriptionAgent identifies a locally installed, user-authenticated model@@ -138,12 +140,15 @@ func (c *SubscriptionAgentClient) TestConnection(ctx context.Context) error {}func (c *SubscriptionAgentClient) Chat(ctx context.Context, req ChatRequest) (*ChatResponse, error) {+ model := c.modelif strings.TrimSpace(req.Model) != "" {- c = &SubscriptionAgentClient{agent: c.agent, model: strings.TrimSpace(req.Model), timeout: c.timeout}+ model = req.Model}- if c.model == "" {- return nil, errors.New("subscription agent model is empty")+ model, err := normalizeSubscriptionAgentModel(c.agent, model)+ if err != nil {+ return nil, err}+ c = &SubscriptionAgentClient{agent: c.agent, model: model, timeout: c.timeout}prompt, err := subscriptionAgentPrompt(req)if err != nil {return nil, err@@ -206,6 +211,25 @@ func (c *SubscriptionAgentClient) Chat(ctx context.Context, req ChatRequest) (*Creturn response.NormalizeCollectionsPtr(), nil}+func normalizeSubscriptionAgentModel(agent SubscriptionAgent, model string) (string, error) {+ model = strings.TrimSpace(model)+ if model == "" {+ return "", errors.New("subscription agent model is empty")+ }+ if !strings.Contains(model, ":") {+ return model, nil+ }+ provider, bareModel := config.ParseModelString(model)+ if provider != string(agent) {+ return "", fmt.Errorf("%s cannot route model for provider %s", agent, provider)+ }+ bareModel = strings.TrimSpace(bareModel)+ if bareModel == "" {+ return "", errors.New("subscription agent model is empty")+ }+ return bareModel, nil+}+// ChatStream adapts the CLI's bounded, structured one-turn response to Pulse's// streaming provider contract. The local subscription CLIs do not expose the// same provider stream as an API transport, so no event is emitted until thediff --git a/internal/ai/providers/subscription_agent_live_test.go b/internal/ai/providers/subscription_agent_live_test.goindex c1dc3fdc5d..31d2371546 100644--- a/internal/ai/providers/subscription_agent_live_test.go+++ b/internal/ai/providers/subscription_agent_live_test.go@@ -34,6 +34,7 @@ func TestSubscriptionAgentLive(t *testing.T) {var toolStarts intvar done DoneEventerr := client.ChatStream(ctx, ChatRequest{+ Model: string(tt.agent) + ":" + tt.model,System: "Select the supplied observation tool exactly once. Do not claim that it ran.",Messages: []Message{{Role: "user", Content: "Inspect node tower using the supplied Pulse tool."}},Tools: []Tool{{Name: "get_node_status", Description: "Read the current status of one node", InputSchema: map[string]interface{}{diff --git a/internal/ai/providers/subscription_agent_test.go b/internal/ai/providers/subscription_agent_test.goindex 2f9dc8d5be..3c10db81eb 100644--- a/internal/ai/providers/subscription_agent_test.go+++ b/internal/ai/providers/subscription_agent_test.go@@ -40,6 +40,40 @@ func TestCappedBufferBoundsChildOutput(t *testing.T) {}}+func TestNormalizeSubscriptionAgentModel(t *testing.T) {+ tests := []struct {+ name string+ agent SubscriptionAgent+ model string+ want string+ wantError string+ }{+ {name: "bare Codex model", agent: SubscriptionAgentCodex, model: "gpt-5.6-luna", want: "gpt-5.6-luna"},+ {name: "qualified Codex model", agent: SubscriptionAgentCodex, model: "codex-subscription:gpt-5.6-luna", want: "gpt-5.6-luna"},+ {name: "qualified Claude model", agent: SubscriptionAgentClaude, model: "claude-subscription:sonnet", want: "sonnet"},+ {name: "foreign subscription route", agent: SubscriptionAgentCodex, model: "claude-subscription:sonnet", wantError: "cannot route model for provider claude-subscription"},+ {name: "API route", agent: SubscriptionAgentCodex, model: "openai:gpt-5.6", wantError: "cannot route model for provider openai"},+ {name: "empty model", agent: SubscriptionAgentCodex, model: " ", wantError: "model is empty"},+ }+ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ got, err := normalizeSubscriptionAgentModel(tt.agent, tt.model)+ if tt.wantError != "" {+ if err == nil || !strings.Contains(err.Error(), tt.wantError) {+ t.Fatalf("normalizeSubscriptionAgentModel() error = %v, want containing %q", err, tt.wantError)+ }+ return+ }+ if err != nil {+ t.Fatal(err)+ }+ if got != tt.want {+ t.Fatalf("normalizeSubscriptionAgentModel() = %q, want %q", got, tt.want)+ }+ })+ }+}+func TestRejectCodexAgentToolActivity(t *testing.T) {if err := rejectCodexAgentToolActivity([]byte("{\"type\":\"item.completed\",\"item\":{\"type\":\"agent_message\"}}\n")); err != nil {t.Fatalf("agent-only event rejected: %v", err)@@ -96,6 +130,13 @@ if [ "$1" = "login" ]; thenexit 0fiwhile [ "$#" -gt 0 ]; do+ if [ "$1" = "--model" ]; then+ shift+ if [ "$1" != "gpt-5.6-luna" ]; then+ echo "unexpected model: $1" >&2+ exit 92+ fi+ fiif [ "$1" = "--output-last-message" ]; thenshiftprintf '%s' '{"content":"","stop_reason":"tool_use","tool_calls":[{"id":"c1","name":"get_node_status","input_json":"{\"node\":\"tower\"}"}]}' > "$1"@@ -127,13 +168,16 @@ printf '%s' '{"structured_output":{"content":"healthy","stop_reason":"end_turn",if err := codex.TestConnection(ctx); err != nil {t.Fatalf("Codex authentication check failed: %v", err)}- response, err := codex.Chat(ctx, ChatRequest{Tools: []Tool{{Name: "get_node_status"}}, ToolChoice: &ToolChoice{Type: ToolChoiceRequired}})+ response, err := codex.Chat(ctx, ChatRequest{Model: "codex-subscription:gpt-5.6-luna", Tools: []Tool{{Name: "get_node_status"}}, ToolChoice: &ToolChoice{Type: ToolChoiceRequired}})if err != nil {t.Fatalf("Codex structured turn failed: %v", err)}if len(response.ToolCalls) != 1 || response.ToolCalls[0].Name != "get_node_status" {t.Fatalf("Codex tool calls = %#v", response.ToolCalls)}+ if response.Model != "gpt-5.6-luna" {+ t.Fatalf("Codex response model = %q, want bare CLI model", response.Model)+ }var streamEvents []StreamEventif err := codex.ChatStream(ctx, ChatRequest{Tools: []Tool{{Name: "get_node_status"}}, ToolChoice: &ToolChoice{Type: ToolChoiceRequired}}, func(event StreamEvent) {streamEvents = append(streamEvents, event)