From 17f92040c732c12d690466fe8bb311209e93d44c Mon Sep 17 00:00:00 2001 From: Lukas May Date: Fri, 6 Mar 2026 12:14:37 +0100 Subject: [PATCH] fix: Ensure agents write signal.json to the correct directory Two additional fixes to prevent agents from writing .cw/output/ in the wrong location: 1. Always create .cw/output/ at the agent workdir root during spawn, even when no inputContext is provided. This gives the agent a visible anchor directory so it doesn't create one inside a project subdir. 2. Add absolute output path instruction to the workspace layout prompt for multi-project agents, explicitly telling them to write .cw/output/ relative to the workdir root, not their current cd location. --- apps/server/agent/manager.ts | 4 ++++ apps/server/agent/prompts/workspace.ts | 2 ++ 2 files changed, 6 insertions(+) diff --git a/apps/server/agent/manager.ts b/apps/server/agent/manager.ts index d567fcc..ac36b83 100644 --- a/apps/server/agent/manager.ts +++ b/apps/server/agent/manager.ts @@ -297,6 +297,10 @@ export class MultiProviderAgentManager implements AgentManager { if (options.inputContext) { await writeInputFiles({ agentWorkdir: agentCwd, ...options.inputContext, agentId, agentName: alias }); log.debug({ alias }, 'input files written'); + } else { + // Always create .cw/output/ at the agent workdir root so the agent + // writes signal.json here rather than in a project subdirectory. + await mkdir(join(agentCwd, '.cw', 'output'), { recursive: true }); } // 4. Build spawn command diff --git a/apps/server/agent/prompts/workspace.ts b/apps/server/agent/prompts/workspace.ts index 846850a..f01c6d3 100644 --- a/apps/server/agent/prompts/workspace.ts +++ b/apps/server/agent/prompts/workspace.ts @@ -36,5 +36,7 @@ This is an isolated git worktree. Other agents may be working in parallel on sep The following project directories contain the source code (git worktrees): ${lines.join('\n')} + +**IMPORTANT**: All \`.cw/output/\` paths (signal.json, progress.md, etc.) are relative to this working directory (\`${agentCwd}\`), NOT to any project subdirectory. Always write to \`${join(agentCwd, '.cw/output/')}\` regardless of your current \`cd\` location. `; }