diff --git a/apps/backend/internal/plugins/host_utility.go b/apps/backend/internal/plugins/host_utility.go index 8d3f8e6e9d..6a0feb26a5 100644 --- a/apps/backend/internal/plugins/host_utility.go +++ b/apps/backend/internal/plugins/host_utility.go @@ -98,7 +98,7 @@ func (h *pluginHost) InvokeUtilityAgent(ctx context.Context, prompt string) (str // utility-agent schema. Keep reading the persisted legacy key even though // the new settings form no longer renders it; plugin config replacement does // not migrate or delete unknown keys. - if hasUtilityAgentConfig(h.configSchema) { + if hasUtilityAgentConfig(h.configSchema) || hasAgentProfileConfig(h.configSchema) { agentID, _ := config[utilityAgentConfigKey].(string) if agentID != "" { return h.invokeConfiguredUtilityAgent(ctx, agentID, agents, runner, prompt) diff --git a/apps/backend/internal/plugins/host_utility_test.go b/apps/backend/internal/plugins/host_utility_test.go index f872332040..fffbdc19e8 100644 --- a/apps/backend/internal/plugins/host_utility_test.go +++ b/apps/backend/internal/plugins/host_utility_test.go @@ -109,7 +109,7 @@ func TestPluginHost_InvokeUtilityAgent_UsesConfiguredAgentProfileBeforeUtilityAg } } -func TestPluginHost_InvokeUtilityAgent_RejectsUndeclaredLegacyUtilityAgentConfig(t *testing.T) { +func TestPluginHost_InvokeUtilityAgent_FallsBackToUndeclaredLegacyUtilityAgentConfig(t *testing.T) { d := configuredUtilityHost(t) d.host.configSchema = map[string]any{ "properties": map[string]any{ @@ -117,15 +117,15 @@ func TestPluginHost_InvokeUtilityAgent_RejectsUndeclaredLegacyUtilityAgentConfig }, } - _, err := d.host.InvokeUtilityAgent(context.Background(), "summarize yesterday") - if status.Code(err) != codes.FailedPrecondition { - t.Fatalf("InvokeUtilityAgent() status = %s, want %s; err = %v", status.Code(err), codes.FailedPrecondition, err) + got, err := d.host.InvokeUtilityAgent(context.Background(), "summarize yesterday") + if err != nil || got != "the summary" { + t.Fatalf("InvokeUtilityAgent() = (%q, %v)", got, err) } - if d.utilAgents.calls != 0 { - t.Fatalf("looked up undeclared utility agent %d times", d.utilAgents.calls) + if d.utilAgents.gotSelector != "utility-agent-42" { + t.Fatalf("looked up utility agent %q", d.utilAgents.gotSelector) } - if d.utilRun.calls != 0 { - t.Fatalf("runner calls = %d, want 0", d.utilRun.calls) + if d.utilRun.gotProfileID != "profile-42" { + t.Fatalf("runner got profile %q", d.utilRun.gotProfileID) } }