From ec3d78922e70e7d33d4e7a6b1be49c790b26c148 Mon Sep 17 00:00:00 2001 From: Stephan Rieche Date: Mon, 29 Dec 2025 23:25:15 +0100 Subject: [PATCH] fix: remove prompt caching to enable hot reload of custom prompts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove caching from Auto Mode and Agent services to allow custom prompts to take effect immediately without requiring app restart. Changes: - Auto Mode: Load prompts on every feature execution instead of caching - Agent Service: Load prompts on every chat message instead of caching - Remove unused class fields: planningPrompts, agentSystemPrompt This makes custom prompts work consistently across all features: ✓ Auto Mode - hot reload enabled ✓ Agent Runner - hot reload enabled ✓ Backlog Plan - already had hot reload ✓ Enhancement - already had hot reload Users can now modify prompts in Settings and see changes immediately without restarting the app. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- apps/server/src/services/agent-service.ts | 10 ++----- apps/server/src/services/auto-mode-service.ts | 30 ++++++------------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/apps/server/src/services/agent-service.ts b/apps/server/src/services/agent-service.ts index 102e6241..77dbb98c 100644 --- a/apps/server/src/services/agent-service.ts +++ b/apps/server/src/services/agent-service.ts @@ -76,7 +76,6 @@ export class AgentService { private metadataFile: string; private events: EventEmitter; private settingsService: SettingsService | null = null; - private agentSystemPrompt: string | null = null; constructor(dataDir: string, events: EventEmitter, settingsService?: SettingsService) { this.stateDir = path.join(dataDir, 'agent-sessions'); @@ -784,12 +783,9 @@ export class AgentService { } private async getSystemPrompt(): Promise { - // Load from settings if not already cached - if (!this.agentSystemPrompt) { - const prompts = await getPromptCustomization(this.settingsService, '[AgentService]'); - this.agentSystemPrompt = prompts.agent.systemPrompt; - } - return this.agentSystemPrompt; + // Load from settings (no caching - allows hot reload of custom prompts) + const prompts = await getPromptCustomization(this.settingsService, '[AgentService]'); + return prompts.agent.systemPrompt; } private generateId(): string { diff --git a/apps/server/src/services/auto-mode-service.ts b/apps/server/src/services/auto-mode-service.ts index a7414541..91723cfa 100644 --- a/apps/server/src/services/auto-mode-service.ts +++ b/apps/server/src/services/auto-mode-service.ts @@ -200,7 +200,6 @@ export class AutoModeService { private config: AutoModeConfig | null = null; private pendingApprovals = new Map(); private settingsService: SettingsService | null = null; - private planningPrompts: Record | null = null; constructor(events: EventEmitter, settingsService?: SettingsService) { this.events = events; @@ -1602,23 +1601,6 @@ Format your response as a structured markdown document.`; return firstLine.substring(0, 57) + '...'; } - /** - * Load planning prompts from settings - */ - private async loadPlanningPrompts(): Promise { - if (this.planningPrompts) { - return; // Already loaded - } - - const prompts = await getPromptCustomization(this.settingsService, '[AutoMode]'); - this.planningPrompts = { - lite: prompts.autoMode.planningLite, - lite_with_approval: prompts.autoMode.planningLiteWithApproval, - spec: prompts.autoMode.planningSpec, - full: prompts.autoMode.planningFull, - }; - } - /** * Get the planning prompt prefix based on feature's planning mode */ @@ -1629,8 +1611,14 @@ Format your response as a structured markdown document.`; return ''; // No planning phase } - // Load prompts if not already loaded - await this.loadPlanningPrompts(); + // Load prompts from settings (no caching - allows hot reload of custom prompts) + const prompts = await getPromptCustomization(this.settingsService, '[AutoMode]'); + const planningPrompts = { + lite: prompts.autoMode.planningLite, + lite_with_approval: prompts.autoMode.planningLiteWithApproval, + spec: prompts.autoMode.planningSpec, + full: prompts.autoMode.planningFull, + }; // For lite mode, use the approval variant if requirePlanApproval is true let promptKey: string = mode; @@ -1638,7 +1626,7 @@ Format your response as a structured markdown document.`; promptKey = 'lite_with_approval'; } - const planningPrompt = this.planningPrompts![promptKey]; + const planningPrompt = planningPrompts[promptKey]; if (!planningPrompt) { return ''; }