Concurrency Queue
Caps concurrent agent operations. Additional requests queue with priority-aware ordering + starvation prevention.
graph TB
A[Agent request] --> B{Slot available?<br/>running < maxConcurrent}
B -->|yes| C[Acquire slot<br/>Status: RUNNING]
B -->|no| D[Queue with priority<br/>Status: WAITING]
D --> E[Sorted: USER > SCHEDULED > BACKGROUND]
E --> F{Slot freed?}
F -->|yes| G[Drain highest priority]
F -->|no| H[Wait with timeout + cancellation]
G --> C
C --> I[Op completes → release → drain next]
Priority levels
Section titled “Priority levels”| Level | Value | Use case |
|---|---|---|
| USER | 2 | Direct user actions (chat, commands) |
| SCHEDULED | 1 | Automated tasks (standup, health check) |
| BACKGROUND | 0 | Background indexing, embedding generation |
Higher priority dequeued first. Within same priority: FIFO.
Starvation prevention
Section titled “Starvation prevention”Background timer runs every 15 s. Any item waiting > 60 s gets bumped up one priority level. BACKGROUND eventually promotes to SCHEDULED, SCHEDULED to USER — no indefinite starvation.
Queue depth
Section titled “Queue depth”maxQueueDepth = maxConcurrent × 10At maxConcurrentStreams = 3, queue holds up to 30 waiting items. Beyond → immediate reject.
Cancellation
Section titled “Cancellation”- AbortSignal — pass an
AbortSignalfor cooperative cancellation. - Timeout — set
timeoutMsdeadline; item rejected if it hasn’t acquired a slot by then.
Commands
Section titled “Commands”| Command | Effect |
|---|---|
| Show Agent Queue Status | Running + waiting items, per-item cancel |
| Cancel All Queued Agent Requests | Cancels all waiting items; running ops NOT interrupted |
Status bar
Section titled “Status bar”Emits onDidChange with { running, waiting, maxConcurrent }. Displays:
Agent: 2/3— 2 slots in use out of 3Agent: 3/3 (2 queued)— full, 2 waiting
Settings
Section titled “Settings”| Setting | Default | Range | Purpose |
|---|---|---|---|
codebuddy.agent.maxConcurrentStreams | 3 | 1–10 | Max concurrent agent streams |
Live-reloads on change. Raising the limit drains queued items into newly available slots.