From 1236919c39b41c8c21684b87249977ec30d126e3 Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Wed, 18 Mar 2026 12:55:16 -0400 Subject: [PATCH] fix: include promptGuidelines in customPrompt path of buildSystemPrompt (#1187) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When buildSystemPrompt() receives a customPrompt (as GSD's contract provides), it returned early without appending promptGuidelines from extension-registered tools. The tool definitions still reached the API's tools parameter, but without prompt guidance the model didn't know when to prefer them — causing subagent tools to be silently ignored in favor of async_bash/bg_shell. Added promptGuidelines append after date/time in the customPrompt path, matching the behavior of the non-custom path. Fixes #1184 --- packages/pi-coding-agent/src/core/system-prompt.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/pi-coding-agent/src/core/system-prompt.ts b/packages/pi-coding-agent/src/core/system-prompt.ts index 235f7d821..310aa9593 100644 --- a/packages/pi-coding-agent/src/core/system-prompt.ts +++ b/packages/pi-coding-agent/src/core/system-prompt.ts @@ -94,6 +94,17 @@ export function buildSystemPrompt(options: BuildSystemPromptOptions = {}): strin prompt += `\nCurrent date and time: ${dateTime}`; prompt += `\nCurrent working directory: ${resolvedCwd}`; + // Append promptGuidelines from extension-registered tools. + // Without this, tools registered via pi.registerTool() with promptGuidelines + // have their definitions reach the API but the model has no guidance on when + // to use them (#1184). + if (promptGuidelines && promptGuidelines.length > 0) { + prompt += "\n\n"; + for (const guideline of promptGuidelines) { + prompt += guideline + "\n"; + } + } + return prompt; }