Agent Roles
Root Planner
Role: Iterative task decomposition and project orchestration Responsibilities:- Break down projects into parallelizable tasks through sprint-based planning
- Maintain awareness of full project scope (SPEC.md, FEATURES.json)
- Process worker handoffs and adapt future sprints based on feedback
- Track unresolved concerns across iterations
- Decide when all work is complete
- Read-only codebase exploration (read, grep, find, ls)
- Read-only git commands (git log, git diff, git show, etc.)
- Continuous conversation with preserved memory via scratchpad
- Write code directly
- Execute tasks themselves
- Make assumptions without exploring the codebase first
Planning Strategy
The root planner operates in sprints, planning only what can be confidently specified:The planner re-plans after receiving MIN_HANDOFFS_FOR_REPLAN (3) handoffs or when no active work remains. This allows rapid adaptation to worker discoveries.
Subplanner
Role: Decompose complex tasks into smaller subtasks When activated:- Task scope exceeds 5 files
- Task spans multiple modules
- Complexity threshold met
- Receive complex task from root planner
- Break it into 2-5 subtasks
- Coordinate execution of subtasks
- Aggregate results into single handoff
- Return to root planner
Subplanners create a hierarchy of work but maintain the illusion of a single task from the root planner’s perspective.
Worker
Role: Execute individual tasks in isolated sandboxes Responsibilities:- Implement the solution described in the task
- Follow acceptance criteria precisely
- Commit all changes to assigned branch
- Write detailed handoffs with concerns and suggestions
Non-Negotiable Constraints
Workers must:- NEVER leave TODOs, placeholders, or partial implementations
- NEVER modify files outside task scope
- NEVER delete or disable tests
- NEVER use
anytypes,@ts-ignore, or@ts-expect-error - ALWAYS commit before handoff
- ALWAYS run verification (compile + test)
Worker Handoff
Every worker returns a detailed handoff:Reconciler
Role: Self-healing system that keeps the main branch green Responsibilities:- Periodically check build and test health
- Detect merge conflict markers, type errors, test failures
- Generate targeted fix tasks when failures detected
- Adjust sweep frequency based on health (adaptive intervals)
- Write code directly
- Fix issues themselves
- Create enhancement tasks
- Handle warnings (errors only)
Sweep Process
Adaptive Sweep Intervals
The reconciler adjusts its checking frequency based on health:- Green state (3+ consecutive passes): Slow down to
maxIntervalMs(5 minutes) - Red state (errors detected): Speed up to
minIntervalMs(1 minute)
Error Priority
When multiple error types exist, reconciler fixes in this order:- Merge conflict markers: Nothing works until resolved
- Build failures: Project cannot be used
- Compiler errors: Type safety violations compound
- Test failures: Functional regressions
Reconciler NEVER creates tasks for multiple priority levels in the same sweep. Lower-priority errors often resolve as side effects of fixing higher-priority ones.
Error Grouping
Reconciler groups related errors into single fix tasks:- Same file, same cause: 5 errors from renamed type → 1 task
- Import chain: File A can’t find export from File B → 1 task scoped to both
- Interface mismatch: Type changed in A, callers in B and C break → 1 task
Agent Communication Flow
Specialized Prompts
Each agent has a specialized system prompt that defines its behavior:- Root Planner:
prompts/root-planner.md— Iterative discovery, sprint planning, scratchpad management - Subplanner:
prompts/subplanner.md— Hierarchical decomposition, subtask coordination - Worker:
prompts/worker.md— Plan-execute-verify workflow, handoff requirements - Reconciler:
prompts/reconciler.md— Error classification, fix task generation
Prompts are loaded from the filesystem and can be customized per deployment without code changes.
Agent Isolation
Workers operate in complete isolation:- Each gets its own ephemeral sandbox (see Sandboxes)
- No visibility into other workers
- No coordination required
- Full filesystem and git access within sandbox
- Access to global task queue and merge queue
- Visibility into all active work
- Can read the target repository directly