Fix: Update system instruction when GEMINI.md memory is loaded or refreshed (#12136)

This commit is contained in:
lifefloating
2025-11-20 21:22:06 +08:00
committed by GitHub
parent 049a299b92
commit 1d2e27a698
4 changed files with 26 additions and 0 deletions
+11
View File
@@ -1020,6 +1020,17 @@ export class Config {
return this.geminiClient;
}
/**
* Updates the system instruction with the latest user memory.
* Whenever the user memory (GEMINI.md files) is updated.
*/
async updateSystemInstructionIfInitialized(): Promise<void> {
const geminiClient = this.getGeminiClient();
if (geminiClient?.isInitialized()) {
await geminiClient.updateSystemInstruction();
}
}
getModelRouterService(): ModelRouterService {
return this.modelRouterService;
}
+10
View File
@@ -168,6 +168,16 @@ export class GeminiClient {
});
}
async updateSystemInstruction(): Promise<void> {
if (!this.isInitialized()) {
return;
}
const userMemory = this.config.getUserMemory();
const systemInstruction = getCoreSystemPrompt(this.config, userMemory);
this.getChat().setSystemInstruction(systemInstruction);
}
async startChat(
extraHistory?: Content[],
resumedSessionData?: ResumedSessionData,