diff --git a/desktop/src/features/agents/ui/personaDialogState.test.mjs b/desktop/src/features/agents/ui/personaDialogState.test.mjs index f476ac829..1f9817013 100644 --- a/desktop/src/features/agents/ui/personaDialogState.test.mjs +++ b/desktop/src/features/agents/ui/personaDialogState.test.mjs @@ -349,8 +349,8 @@ test("saveAsPersonaTemplateDialogState carries name, prompt, model, and envVars" test("saveAsPersonaTemplateDialogState carries the provider id from a provider backend", () => { // A databricks/anthropic agent must promote with its provider, not lose it. - // The canonical provider source is backend.id (the create input), not the - // derived top-level ManagedAgent.provider snapshot. + // backend.id is the canonical source: top-level ManagedAgent.provider is a + // persona-pinned snapshot and is null for the persona-less agents this acts on. const state = saveAsPersonaTemplateDialogState( makeAgent({ backend: { type: "provider", id: "databricks", config: {} } }), [], diff --git a/desktop/src/features/agents/ui/personaDialogState.ts b/desktop/src/features/agents/ui/personaDialogState.ts index 190adae19..24571d519 100644 --- a/desktop/src/features/agents/ui/personaDialogState.ts +++ b/desktop/src/features/agents/ui/personaDialogState.ts @@ -94,12 +94,15 @@ function runtimeIdForAgentCommand( * Extract the LLM provider id from a managed agent's backend so it can carry * into the persona template (a databricks/anthropic agent should promote with * its provider, not lose it). The canonical provider source is the backend - * union, not the top-level `provider` field on `ManagedAgent`: that top-level - * field is a derived snapshot (output), while a `"provider"` backend carries - * the provider id that was the actual create input. A `"local"` backend has - * none. Returns `undefined` for local backends — the persona's `provider` is - * optional, so an absent provider just carries as unset (auto-detect / - * provider-locked runtime). + * union, NOT the top-level `provider` field on `ManagedAgent`. That top-level + * field is a persona-pinned snapshot: `create_managed_agent` only fills it + * from a linked persona's snapshot (commands/agents.rs), so it is `null` for + * the persona-less agents this feature acts on (`personaId === null`) — while + * `backend` always preserves the real `{ type: "provider"; id }` from the + * create input. Reading top-level `provider` here would lose the provider on + * exactly those agents. A `"local"` backend has none. Returns `undefined` for + * local backends — the persona's `provider` is optional, so an absent provider + * just carries as unset (auto-detect / provider-locked runtime). */ function providerForAgentBackend( backend: ManagedAgent["backend"],