From 48b6510c18e3499d462ade5c656fc2db7cc8eaa9 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Tue, 19 May 2026 18:01:10 +0200 Subject: [PATCH] fix(coding-agent): clarify pi docs path resolution closes #4752 --- packages/coding-agent/CHANGELOG.md | 1 + packages/coding-agent/src/core/system-prompt.ts | 1 + packages/coding-agent/test/system-prompt.test.ts | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index d664d11a..c190751a 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -4,6 +4,7 @@ ### Fixed +- Fixed the system prompt to tell models to resolve pi docs and examples under the absolute package paths before reading topic-specific relative references ([#4752](https://github.com/earendil-works/pi/issues/4752)). - Fixed extension `ctx.abort()` during tool-call preflight to stop later confirmations and restore queued interactive input like Escape ([#4276](https://github.com/earendil-works/pi/issues/4276)). - Fixed AgentSession retry, compaction, and event settlement to use the awaited agent lifecycle instead of a separate event queue, and added `willRetry` to `agent_end` session events. - Fixed the subagent extension's parallel mode to return useful per-task output and failed-task diagnostics to the parent model instead of 100-character previews ([#4710](https://github.com/earendil-works/pi/issues/4710)). diff --git a/packages/coding-agent/src/core/system-prompt.ts b/packages/coding-agent/src/core/system-prompt.ts index a88b41b3..c6b1017d 100644 --- a/packages/coding-agent/src/core/system-prompt.ts +++ b/packages/coding-agent/src/core/system-prompt.ts @@ -143,6 +143,7 @@ Pi documentation (read only when the user asks about pi itself, its SDK, extensi - Main documentation: ${readmePath} - Additional docs: ${docsPath} - Examples: ${examplesPath} (extensions, custom tools, SDK) +- When reading pi docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory - When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md) - When working on pi topics, read the docs and examples, and follow .md cross-references before implementing - Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`; diff --git a/packages/coding-agent/test/system-prompt.test.ts b/packages/coding-agent/test/system-prompt.test.ts index 31a5d6b4..bdc19056 100644 --- a/packages/coding-agent/test/system-prompt.test.ts +++ b/packages/coding-agent/test/system-prompt.test.ts @@ -45,6 +45,18 @@ describe("buildSystemPrompt", () => { expect(prompt).toContain("- edit:"); expect(prompt).toContain("- write:"); }); + + test("instructs models to resolve pi docs and examples under absolute base paths", () => { + const prompt = buildSystemPrompt({ + contextFiles: [], + skills: [], + cwd: process.cwd(), + }); + + expect(prompt).toContain( + "- When reading pi docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory", + ); + }); }); describe("custom tool snippets", () => {