From 462b3d21e32d07c262e6fb41e1e6c478be7af3c0 Mon Sep 17 00:00:00 2001 From: nathyong Date: Wed, 15 Apr 2026 04:33:05 +1000 Subject: [PATCH] fix(coding-agent): do not inject bunfs script path into subagent prompts (#3002) The presence of `process.argv[1]` in the current invocation does not imply that the current `pi` process is being invoked as a script. Specifically, in the case of a bun compiled binary, `process.argv[1]` will be the virtual path `/$bunfs/root/pi`, which is not a real file on the filesystem. This causes the subagent extension to inject this path into the child `pi` invocation, which is interpreted as part of the prompt, which confuses the subagent. This change uses the script only if it is not a bunfs virtual script Co-authored-by: nathyong --- packages/coding-agent/examples/extensions/subagent/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/coding-agent/examples/extensions/subagent/index.ts b/packages/coding-agent/examples/extensions/subagent/index.ts index 7e5276d6..ca65341d 100644 --- a/packages/coding-agent/examples/extensions/subagent/index.ts +++ b/packages/coding-agent/examples/extensions/subagent/index.ts @@ -219,7 +219,8 @@ async function writePromptToTempFile(agentName: string, prompt: string): Promise function getPiInvocation(args: string[]): { command: string; args: string[] } { const currentScript = process.argv[1]; - if (currentScript && fs.existsSync(currentScript)) { + const isBunVirtualScript = currentScript?.startsWith("/$bunfs/root/"); + if (currentScript && !isBunVirtualScript && fs.existsSync(currentScript)) { return { command: process.execPath, args: [currentScript, ...args] }; }