Parallel Task Execution
How CodeSpar runs multiple coding tasks concurrently.
Parallel Task Execution
CodeSpar can run up to 3 concurrent tasks per Project Agent. When you send multiple instruct or fix commands in quick succession, each spawns its own Task Agent and runs in parallel -- no need to wait for one to finish before starting the next.
How It Works
Each Project Agent maintains an activeTaskCount and a taskQueue. When a new task arrives:
- If
activeTaskCount < 3, the task starts immediately in a new Task Agent - If all 3 slots are busy, the task is added to the
taskQueuewith a position number - When any running task completes, the next task in the queue is automatically dequeued and started
Queue Feedback
When a task is queued, you get immediate feedback with the queue position:
When the task is dequeued and starts:
Example: Running Tasks in Parallel
Send three tasks in quick succession:
All three tasks run simultaneously, each in its own Task Agent with its own Claude session. As each completes, you receive the results independently:
Automatic Dequeue
When a running task completes, the Project Agent automatically starts the next queued task:
The dequeue process is automatic and immediate. You do not need to run any command to start queued tasks.
Limitations
Shared Repository Context
All concurrent tasks operate on the same repository. This means:
- Each task reads the current state of the codebase when it starts
- Tasks do not see changes made by other concurrent tasks until those changes are merged
- If two tasks modify the same file, the resulting PRs may have merge conflicts
For tasks that need to build on each other's changes, use the Planning Agent instead, which executes steps sequentially with context from previous steps.
No Dependency Ordering
Parallel execution has no concept of task dependencies. All tasks in the queue are treated as independent and start in FIFO order. If your tasks have dependencies (e.g., "create the model first, then write the API endpoint"), use the Planning Agent for ordered execution.
Concurrency Limit
The limit of 3 concurrent tasks is per Project Agent, not per CodeSpar instance. If you have multiple projects, each project's agent can run 3 tasks in parallel independently.
When to Use Parallel Tasks vs. Planning Agent
| Scenario | Approach |
|---|---|
| Independent endpoints or features | Parallel tasks (instruct x3) |
| Tests for different modules | Parallel tasks |
| Sequential steps with dependencies | Planning Agent (plan) |
| Large feature with ordered sub-tasks | Planning Agent (plan) |
| Quick fixes to unrelated bugs | Parallel tasks (fix x3) |