fix: propagate authProfile through message chain to Auth.get

- message-v2.ts: add authProfile to User.model schema
- prompt.ts: copy authProfile from model to userMsg.model
- lllm.ts: build auth key with profile when calling Auth.get()
- acp/types.ts: add authProfile to ACPSessionState.model
- acp/agent.ts: propagate authProfile in setModel call

This fixes the bug where embedded profiles (e.g., 'minimax-coding-plan:personal')
were lost when creating user messages and never reached Auth.get().
pull/21353/head
PabloGNU 2026-04-07 15:20:13 +02:00
parent cf0c0cee25
commit 2748cf9585
5 changed files with 11 additions and 2 deletions

View File

@ -659,6 +659,7 @@ export namespace ACP {
this.sessionManager.setModel(sessionId, {
providerID: ProviderID.make(lastUser.model.providerID),
modelID: ModelID.make(lastUser.model.modelID),
authProfile: (lastUser.model as { authProfile?: string }).authProfile,
})
if (result.modes?.availableModes.some((m) => m.id === lastUser.agent)) {
result.modes.currentModeId = lastUser.agent

View File

@ -10,6 +10,7 @@ export interface ACPSessionState {
model?: {
providerID: ProviderID
modelID: ModelID
authProfile?: string
}
variant?: string
modeId?: string

View File

@ -94,7 +94,9 @@ export namespace LLM {
Provider.getLanguage(input.model),
Config.get(),
Provider.getProvider(input.model.providerID),
Auth.get(input.model.providerID),
Auth.get(
input.model.authProfile ? `${input.model.providerID}:${input.model.authProfile}` : input.model.providerID,
),
])
// TODO: move this to a proper hook
const isOpenaiOauth = provider.id === "openai" && auth?.type === "oauth"

View File

@ -371,6 +371,7 @@ export namespace MessageV2 {
model: z.object({
providerID: ProviderID.zod,
modelID: ModelID.zod,
authProfile: z.string().optional(),
}),
system: z.string().optional(),
tools: z.record(z.string(), z.boolean()).optional(),

View File

@ -761,7 +761,11 @@ NOTE: At any point in time through this workflow you should feel free to ask the
time: { created: Date.now() },
role: "user",
agent: input.agent,
model: { providerID: model.providerID, modelID: model.modelID },
model: {
providerID: model.providerID,
modelID: model.modelID,
authProfile: (model as { authProfile?: string }).authProfile,
},
}
yield* sessions.updateMessage(userMsg)
const userPart: MessageV2.Part = {