fix(coding-agent): refresh active model after provider updates closes #2291

This commit is contained in:
Mario Zechner
2026-03-18 01:12:11 +01:00
parent 1a9185d3cb
commit 2becbbdff3
3 changed files with 169 additions and 4 deletions

View File

@@ -2057,6 +2057,20 @@ export class AgentSession {
: undefined;
}
private _refreshCurrentModelFromRegistry(): void {
const currentModel = this.model;
if (!currentModel) {
return;
}
const refreshedModel = this._modelRegistry.find(currentModel.provider, currentModel.id);
if (!refreshedModel || refreshedModel === currentModel) {
return;
}
this.agent.setModel(refreshedModel);
}
private _bindExtensionCore(runner: ExtensionRunner): void {
const normalizeLocation = (source: string): SlashCommandLocation | undefined => {
if (source === "user" || source === "project" || source === "path") {
@@ -2165,6 +2179,16 @@ export class AgentSession {
},
getSystemPrompt: () => this.systemPrompt,
},
{
registerProvider: (name, config) => {
this._modelRegistry.registerProvider(name, config);
this._refreshCurrentModelFromRegistry();
},
unregisterProvider: (name) => {
this._modelRegistry.unregisterProvider(name);
this._refreshCurrentModelFromRegistry();
},
},
);
}