fix(agent): save original provider ID instead of alias in session meta

setProvider() was saving the alias-resolved provider (e.g. "anthropic"
instead of "claude-code") to session metadata. On restart, this caused
the wrong provider to be selected. Now saves the original providerId
so the exact user selection is preserved.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jiang Bohan 2026-02-09 15:45:11 +08:00
parent 15f6604a16
commit 2fa8c383fb

View file

@ -316,7 +316,7 @@ export class Agent {
}
this.session.saveMeta({
provider: this.agent.state.model?.provider,
provider: this.resolvedProvider,
model: this.agent.state.model?.id,
thinkingLevel: this.agent.state.thinkingLevel,
reasoningMode: this.reasoningMode,
@ -874,9 +874,9 @@ export class Agent {
// Update internal state
this.resolvedProvider = providerId;
// Update session metadata
// Update session metadata (save original providerId, not alias-resolved)
this.session.saveMeta({
provider: actualProvider,
provider: providerId,
model: model.id,
thinkingLevel: this.agent.state.thinkingLevel,
reasoningMode: this.reasoningMode,