perf: Speed up conflict resolution agents by trimming prompt bloat

Replace SESSION_STARTUP (full test suite run) and CONTEXT_MANAGEMENT
(progress file refs) with a minimal startup block (pwd, git status,
CLAUDE.md). Add skipPromptExtras option to SpawnAgentOptions to skip
inter-agent communication and preview deployment instructions. Conflict
agents now go straight to the resolution protocol — one post-resolution
test run instead of two.
This commit is contained in:
Lukas May
2026-03-06 14:05:23 +01:00
parent a0574a1ae9
commit b419981924
5 changed files with 19 additions and 13 deletions

View File

@@ -283,14 +283,15 @@ export class MultiProviderAgentManager implements AgentManager {
}); });
const agentId = agent.id; const agentId = agent.id;
// 3a. Append inter-agent communication instructions with actual agent ID // 3a. Append inter-agent communication + preview instructions (skipped for focused agents)
prompt = prompt + buildInterAgentCommunication(agentId, mode); if (!options.skipPromptExtras) {
prompt = prompt + buildInterAgentCommunication(agentId, mode);
// 3b. Append preview deployment instructions if applicable if (['execute', 'refine', 'discuss'].includes(mode) && initiativeId) {
if (['execute', 'refine', 'discuss'].includes(mode) && initiativeId) { const shouldInject = await this.shouldInjectPreviewInstructions(initiativeId);
const shouldInject = await this.shouldInjectPreviewInstructions(initiativeId); if (shouldInject) {
if (shouldInject) { prompt = prompt + buildPreviewInstructions(agentId);
prompt = prompt + buildPreviewInstructions(agentId); }
} }
} }

View File

@@ -5,9 +5,7 @@
import { import {
SIGNAL_FORMAT, SIGNAL_FORMAT,
SESSION_STARTUP,
GIT_WORKFLOW, GIT_WORKFLOW,
CONTEXT_MANAGEMENT,
} from './shared.js'; } from './shared.js';
export function buildConflictResolutionPrompt( export function buildConflictResolutionPrompt(
@@ -29,7 +27,12 @@ You are a Conflict Resolution agent. Your job is to merge \`${targetBranch}\` in
${conflictList} ${conflictList}
</conflict_details> </conflict_details>
${SIGNAL_FORMAT} ${SIGNAL_FORMAT}
${SESSION_STARTUP}
<session_startup>
1. \`pwd\` — confirm working directory
2. \`git status\` — check branch state
3. Read \`CLAUDE.md\` at the repo root (if it exists) — it contains project conventions you must follow.
</session_startup>
<resolution_protocol> <resolution_protocol>
Follow these steps in order: Follow these steps in order:
@@ -57,7 +60,6 @@ Follow these steps in order:
8. **Signal done**: Write signal.json with status "done". 8. **Signal done**: Write signal.json with status "done".
</resolution_protocol> </resolution_protocol>
${GIT_WORKFLOW} ${GIT_WORKFLOW}
${CONTEXT_MANAGEMENT}
<important> <important>
- You are on a temporary branch created from ${sourceBranch}. You are merging ${targetBranch} INTO this branch — bringing it up to date, NOT the other way around. - You are on a temporary branch created from ${sourceBranch}. You are merging ${targetBranch} INTO this branch — bringing it up to date, NOT the other way around.

View File

@@ -61,6 +61,8 @@ export interface SpawnAgentOptions {
branchName?: string; branchName?: string;
/** Context data to write as input files in agent workdir */ /** Context data to write as input files in agent workdir */
inputContext?: AgentInputContext; inputContext?: AgentInputContext;
/** Skip inter-agent communication and preview instructions (for focused agents like conflict resolution) */
skipPromptExtras?: boolean;
} }
/** /**

View File

@@ -488,6 +488,7 @@ export function initiativeProcedures(publicProcedure: ProcedureBuilder) {
initiativeId: input.initiativeId, initiativeId: input.initiativeId,
baseBranch: initiative.branch, baseBranch: initiative.branch,
branchName: tempBranch, branchName: tempBranch,
skipPromptExtras: true,
}); });
}), }),
}; };

View File

@@ -24,14 +24,14 @@
| `accounts/` | Account discovery, config dir setup, credential management, usage API | | `accounts/` | Account discovery, config dir setup, credential management, usage API |
| `credentials/` | `AccountCredentialManager` — credential injection per account | | `credentials/` | `AccountCredentialManager` — credential injection per account |
| `lifecycle/` | `LifecycleController` — retry policy, signal recovery, missing signal instructions | | `lifecycle/` | `LifecycleController` — retry policy, signal recovery, missing signal instructions |
| `prompts/` | Mode-specific prompt builders (execute, discuss, plan, detail, refine, chat, conflict-resolution, errand) + shared blocks (test integrity, deviation rules, git workflow, session startup, progress tracking) + inter-agent communication instructions | | `prompts/` | Mode-specific prompt builders (execute, discuss, plan, detail, refine, chat, conflict-resolution, errand) + shared blocks (test integrity, deviation rules, git workflow, session startup, progress tracking) + inter-agent communication instructions. Conflict-resolution uses a minimal inline startup (pwd, git status, CLAUDE.md) instead of the full `SESSION_STARTUP`/`CONTEXT_MANAGEMENT` blocks. |
## Key Flows ## Key Flows
### Spawning an Agent ### Spawning an Agent
1. **tRPC procedure** calls `agentManager.spawn(options)` 1. **tRPC procedure** calls `agentManager.spawn(options)`
2. Manager generates alias (adjective-animal), creates DB record 2. Manager generates alias (adjective-animal), creates DB record. Appends inter-agent communication and preview instructions unless `skipPromptExtras: true` (used by conflict-resolution agents to keep prompts lean).
3. `AgentProcessManager.createWorktree()` — creates git worktree at `.cw-worktrees/agent/<alias>/` 3. `AgentProcessManager.createWorktree()` — creates git worktree at `.cw-worktrees/agent/<alias>/`
4. `file-io.writeInputFiles()` — writes `.cw/input/` with assignment files (initiative, pages, phase, task) and read-only context dirs (`context/phases/`, `context/tasks/`) 4. `file-io.writeInputFiles()` — writes `.cw/input/` with assignment files (initiative, pages, phase, task) and read-only context dirs (`context/phases/`, `context/tasks/`)
5. Provider config builds spawn command via `buildSpawnCommand()` 5. Provider config builds spawn command via `buildSpawnCommand()`