Commit d9522065c72d

Vincent Demeester <vincent@sbr.pm>
2026-02-06 21:58:11
debug(pi): add defensive check for undefined working directory in subagent
Added check to catch undefined working directory before spawn. This should give us a clearer error message about what's undefined.
1 parent 195df09
Changed files (1)
dots
pi
agent
extensions
subagent
dots/pi/agent/extensions/subagent/index.ts
@@ -283,7 +283,11 @@ async function runSingleAgent(
 		let wasAborted = false;
 
 		const exitCode = await new Promise<number>((resolve) => {
-			const proc = spawn("pi", args, { cwd: cwd ?? defaultCwd, shell: false, stdio: ["ignore", "pipe", "pipe"] });
+			const workingDir = cwd ?? defaultCwd;
+			if (!workingDir) {
+				throw new Error(`Working directory is undefined. cwd=${cwd}, defaultCwd=${defaultCwd}`);
+			}
+			const proc = spawn("pi", args, { cwd: workingDir, shell: false, stdio: ["ignore", "pipe", "pipe"] });
 			let buffer = "";
 
 			const processLine = (line: string) => {