From c9a20a3aa432132b620569fbd4e0347dea98f37b Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 2 Feb 2026 23:56:20 +0100 Subject: [PATCH] fix(coding-agent): normalize @ path prefixes closes #1206 --- packages/coding-agent/docs/extensions.md | 2 ++ packages/coding-agent/src/core/tools/path-utils.ts | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/coding-agent/docs/extensions.md b/packages/coding-agent/docs/extensions.md index e2e66d72..93b7ee59 100644 --- a/packages/coding-agent/docs/extensions.md +++ b/packages/coding-agent/docs/extensions.md @@ -1130,6 +1130,8 @@ export default function (pi: ExtensionAPI) { Register tools the LLM can call via `pi.registerTool()`. Tools appear in the system prompt and can have custom rendering. +Note: Some models are idiots and include the @ prefix in tool path arguments. Built-in tools strip a leading @ before resolving paths. If your custom tool accepts a path, normalize a leading @ as well. + ### Tool Definition ```typescript diff --git a/packages/coding-agent/src/core/tools/path-utils.ts b/packages/coding-agent/src/core/tools/path-utils.ts index 051c1bf5..3b5b8e2f 100644 --- a/packages/coding-agent/src/core/tools/path-utils.ts +++ b/packages/coding-agent/src/core/tools/path-utils.ts @@ -32,8 +32,12 @@ function fileExists(filePath: string): boolean { } } +function normalizeAtPrefix(filePath: string): string { + return filePath.startsWith("@") ? filePath.slice(1) : filePath; +} + export function expandPath(filePath: string): string { - const normalized = normalizeUnicodeSpaces(filePath); + const normalized = normalizeUnicodeSpaces(normalizeAtPrefix(filePath)); if (normalized === "~") { return os.homedir(); }