refactor: Wire buildExecutePrompt into dispatch manager

Dispatch manager now wraps task descriptions with buildExecutePrompt()
so agents receive the full execution protocol. Update test to match
prompt wrapping. Add worktree isolation note to workspace layout.
This commit is contained in:
Lukas May
2026-02-18 17:40:03 +09:00
parent b63a8b605c
commit 1331fb737d
3 changed files with 6 additions and 4 deletions

View File

@@ -16,7 +16,7 @@ export function buildWorkspaceLayout(agentCwd: string): string {
}
if (entries.length === 0) {
return `\n\n## Workspace Layout\n\nYour working directory is: ${agentCwd}`;
return `\n\n## Workspace Layout\n\nYour working directory is: ${agentCwd}\nThis is an isolated git worktree. Other agents may be working in parallel on separate branches — do not assume you have exclusive access to the repository.`;
}
const lines = entries.map(
@@ -26,6 +26,7 @@ export function buildWorkspaceLayout(agentCwd: string): string {
return `\n\n## Workspace Layout
Your working directory is: ${agentCwd}
This is an isolated git worktree. Other agents may be working in parallel on separate branches — do not assume you have exclusive access to the repository.
The following project directories contain the source code (git worktrees):
${lines.join('\n')}`;

View File

@@ -397,11 +397,11 @@ describe('DefaultDispatchManager', () => {
const updatedTask = await taskRepository.findById(task.id);
expect(updatedTask!.status).toBe('in_progress');
// Check spawn was called with correct params
// Check spawn was called with correct params (prompt is wrapped by buildExecutePrompt)
expect(agentManager.spawn).toHaveBeenCalledWith(
expect.objectContaining({
taskId: task.id,
prompt: 'Do the thing',
prompt: expect.stringContaining('Do the thing'),
})
);
});

View File

@@ -23,6 +23,7 @@ import type { PhaseRepository } from '../db/repositories/phase-repository.js';
import type { Task } from '../db/schema.js';
import type { DispatchManager, QueuedTask, DispatchResult } from './types.js';
import { phaseBranchName, taskBranchName, isPlanningCategory, generateInitiativeBranch } from '../git/branch-naming.js';
import { buildExecutePrompt } from '../agent/prompts/index.js';
import { createModuleLogger } from '../logger/index.js';
const log = createModuleLogger('dispatch');
@@ -371,7 +372,7 @@ export class DefaultDispatchManager implements DispatchManager {
taskId: nextTask.taskId,
initiativeId: task.initiativeId ?? undefined,
phaseId: task.phaseId ?? undefined,
prompt: task.description || task.name,
prompt: buildExecutePrompt(task.description || task.name),
baseBranch,
branchName,
});