fix(core): rebuild system prompt after provider switch

setProvider() updated the resolved provider and model but did not
rebuild the system prompt, so the runtime info line still showed the
old provider/model (e.g. claude-code/claude-opus-4-6) after switching.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jiayuan Zhang 2026-02-11 00:12:08 +08:00
parent 0135951ac6
commit afe51d325d

View file

@ -905,6 +905,14 @@ export class Agent {
contextWindowTokens: this.contextWindowGuard.tokens,
});
// Rebuild system prompt so runtime info reflects the new provider/model
const toolNames = (this.agent.state.tools ?? []).map((t: { name: string }) => t.name);
const systemPrompt = this.rebuildSystemPrompt(toolNames);
if (systemPrompt) {
this.agent.setSystemPrompt(systemPrompt);
this.session.setSystemPrompt(systemPrompt);
}
return {
provider: providerId,
model: model.id,