iCode Workbench · Guide · Queue

How to queue coding agent tasks

A terminal tab is a process, not a task. When you run more than one agent, the question stops being “which tab is running?” and becomes “what work is queued, what is running, what needs me, and what is ready to review?” A queue answers the second question.

This guide covers the state model, retries, schedules, slot limits, and the review gate — the parts of a queue that make a fleet legible.

This guide is currently available in English only.

Terminal tabs vs a queue

A tab shows you a process. It does not tell you what the process is for, what it is waiting on, whether it is blocked, or whether the result has been reviewed. With one agent, you can hold that in your head. With three, you cannot.

A queue makes the task the primary object. A task has a goal, an owner, a state, and a history. The agent is an implementation detail: it may be Claude Code today and Codex tomorrow. The task outlives the session.

Terminal tabsTask queue
Primary objectProcessTask
StateRunning or notQueued, running, waiting, failed, completed
HistoryScrollbackAttempts, retries, review decision
ReviewManualA separate decision on the task
Survives a restartNoYes, if the task state is durable

The state model

A useful queue has explicit states. The exact names matter less than the distinctions:

  • Queued. The task exists and is waiting for a slot. Nothing is running yet.
  • Dispatching. A slot opened and the task is being assigned to a session. This is a short state, but it makes the transition visible.
  • Running. The agent is working. Running is not the same as “will succeed,” and it is not the same as “reviewed.”
  • Waiting. The agent needs a person: an approval, a decision, or an answer. Waiting is not failed, and it is not running.
  • Completed. The process exited successfully. The task still needs a review decision before it is accepted.
  • Failed. The process exited with an error, or the verification command failed. A retry creates a new attempt.
  • Cancelled. A person stopped the task. It should not silently reappear.

Without these distinctions, a fleet looks like a wall of green. A false green is worse than an honest unknown: it tells you not to look.

What a task should contain

A queue is only as good as the task it holds. A vague task produces a vague diff, and no amount of state management fixes that. A useful task has five fields:

  1. A goal in one sentence. “Fix the token refresh path,” not “improve auth.”
  2. Owned paths. The files or directories the agent may change. Everything else is out of scope unless it announces the change.
  3. A done-when command. The verification the agent must run, and you will run again. “The auth tests pass” is better than “it works.”
  4. An out-of-scope list. The changes you do not want: public types, route tables, migrations, formatting. This is where agent drift gets caught.
  5. A baseline. The commit or worktree state the task started from, so the review can compare against it.

A sixth field — the review owner — is useful once more than one person can accept work. The queue should know who is expected to decide, not just who is expected to run.

Retries

A retry is a new attempt, not an erased failure. The previous attempt should stay in the task history: what the agent tried, why it failed, and what changed. If the retry succeeds, you still want to review the final diff; if it fails again, you want to see the pattern.

Retries also interact with review. A retry should never count as a review, and a successful retry should not auto-merge. The task’s review decision is independent of how many attempts it took.

Keep the retry policy simple: retry a failed verification, do not retry a failed review without a change, and do not retry a task that is waiting on a person. For the full model, read agent task states, retries, and schedules.

Schedules

Recurring work belongs in the same queue. A schedule creates an ordinary queued task on a cadence — once, daily, weekdays, weekly, or every few hours. The schedule is not a separate automation with its own failure modes; it is a task factory.

The important design decision is overlap. If the previous run is still running when the next one is due, you can queue the new one or skip it. Pick one explicitly. A nightly audit that silently stacks up ten concurrent runs is worse than a nightly audit that skips a night.

Slot limits

A slot limit is a feature, not a restriction. It bounds concurrency to what you can review, not to what the machine can run. Start with two slots. Add a third only when the first two are merging cleanly and the review queue is consistently empty.

The limit also makes the queue useful: if every task runs immediately, the queue is just a launcher. The queued state is where prioritization happens. For a way to choose the number, read how many coding agents should you run in parallel?

Where the queue lives

The queue should outlive the terminal. If task state lives only in scrollback, closing the app erases the history and the work becomes invisible even if the branch survives.

Local-first queue state — a local database or file — has two advantages: it survives restarts without a network, and it keeps the task history on the machine. That matters when the tasks include repository names, paths, and diffs you would rather not send to a hosted service.

A hosted queue can be useful for a team, but make the trade-off explicit. The question is not “local or cloud” as an ideology; it is whether the state is durable, who can read it, and what happens when the service is unavailable.

The review gate

A queue that ends at “completed” is not a workbench; it is a process manager. The review decision is what turns a completed task into accepted work.

Review in the checkout where the agent worked, against the baseline the task started from. Read the diff, run the verification command, and make a decision that is separate from process exit. A task can complete and still be rejected; a rejected task can be revised and re-reviewed.

For the review workflow itself, read the review gate, and how to review AI-generated code.

Common mistakes

  • Too many slots. If the queue is always empty, you are not reviewing. Concurrency should track review capacity, not machine capacity.
  • Retrying a failed review without a change. A retry with the same task and the same diff produces the same review. Change the task or the code first.
  • Schedules that stack. A nightly audit with no overlap policy becomes ten concurrent audits. Choose queue-or-skip explicitly.
  • A queue without a review gate. Completed is not accepted. If the queue ends at process exit, it is a launcher, not a workbench.
  • Using the queue as a to-do list. A queue without a slot limit and a review decision is a backlog. The value is in the bounded concurrency and the decision.

A worked example

Five tasks: an auth fix, a billing refactor, a flaky test, a migration, and a docs update. You have two slots and one reviewer.

  1. Queue all five. The migration and auth fix are independent; the billing refactor depends on the auth session type; the docs update depends on the auth flow.
  2. Run the migration and auth fix first. Two slots, two independent tasks. The billing, test, and docs tasks wait.
  3. Review the migration before starting billing. If the migration changes the session table, the billing branch should start from the new schema, not the old one.
  4. Retry the flaky test as a new attempt. If the first attempt only skips the test, reject it. A retry should change the diagnosis, not the assertion.
  5. Run the docs task last. It depends on the auth flow, and it is the lowest-risk diff. Do not let it consume a slot that a code task needs.

The queue is doing two jobs here: bounding concurrency and encoding dependencies. A pile of terminal tabs can do neither.