iCode Workbench · Blog · Queue

Durable tasks, not terminal tabs: running a queue of agent work

A terminal tab is a process. A task is a unit of work. Most agent workflows confuse the two: closing the window kills the process, closing the conversation loses the state, and a green exit gets treated as a finished job. The queue is the abstraction that separates them.

This essay is currently available in English only.

The tab is not the task

A tab is bound to a window. Close the window and the process dies; reopen it and you get a new shell with no memory of what was running. If the agent was halfway through a refactor, the work is not “paused.” It is gone, unless something outside the terminal remembers it.

A task should outlive the window. It should survive a closed app, a sleeping session, and a failed attempt. It should still be there tomorrow, with its instruction, its checkout, its state, and its review decision intact.

That is the difference between a terminal tab and a task queue.

What a task contains

A durable task carries five things:

An instruction.

What to do, what must stay true, what “done” means, and what is out of scope. Without this, the agent is guessing and the reviewer is guessing about the guess.

A checkout.

Each task runs in its own Git worktree and branch, so two tasks in the same repository do not edit the same files by accident.

A session.

The agent process that does the work. The session can sleep and wake; the terminal can outlive the window; the checkout stays on disk.

A state.

Queued, dispatching, running, waiting, completed, failed, cancelled. The state is what makes a fleet legible.

A review decision.

Separate from the process state. A task can complete and still be rejected. A task is not done because it exited; it is done because someone reviewed the result.

A task without a review decision is just a process that stopped.

The state machine

The states are not decoration. Each one tells you what the system is doing and what it needs from you.

  • Queued. The task is waiting for a slot. Nothing has started.
  • Dispatching. The worktree and session are being set up.
  • Running. The agent is working.
  • Waiting. The agent needs input — a permission prompt, a decision, a missing credential.
  • Completed. The process exited successfully.
  • Failed. The process exited with an error.
  • Cancelled. A person stopped it.

The important distinction is between completed and reviewed. “Completed” is a process fact. “Reviewed” is a judgment. A queue that treats the first as the second has no gate.

The second important distinction is between waiting and stuck. A waiting task is not a failure; it is a task that needs a person. The state makes that visible instead of leaving you to guess from a silent terminal.

The slot limit

A queue with no limit is a pile. Workbench uses a global 1–4 slot limit for queued tasks. Start at two.

The limit is not there to make the product feel safe. It is there because parallel work contends for the same machine resources: ports, databases, CPU, and your attention. A queue that dispatches everything at once will produce a fleet of half-finished tasks and a reviewer who cannot keep up.

Bounded concurrency also makes the queue useful. When all slots are full, a new task waits in a known place. It is not lost, it is not silently dropped, and it is not competing for the same port as the task in front of it.

A queue also gives you a place to put work that should not start yet. A backlog is a list; a queue has a head, a state, and a reason. When a task waits, you can see why: no slot, a dependency, or a person needed.

Retries are new attempts

A retry is a new attempt, not an erasure of the failed one.

That distinction matters because the failed attempt is evidence. It has logs, a diff, a partial state, and a reason it did not work. If a retry overwrites the record, you lose the only material that tells you whether the next attempt is different.

A retry should be a deliberate decision: this attempt failed for a reason, and here is what changes. “Try again until green” is not a queue policy; it is a loop that hides the defect.

Schedules are ordinary tasks

Recurring work should not live in a separate automation system with its own failures. A schedule creates an ordinary queued task on a cadence — once, daily, weekdays, weekly, or every few hours.

The useful details are mundane:

  • Queue-or-skip overlap handling. If the previous occurrence is still running, the next one can wait or be skipped.
  • Run-now. You can trigger an occurrence without waiting for the cadence.
  • Pausing is not deleting. Pausing a schedule leaves tasks already created untouched.
  • Every occurrence lands in the same queue as work you queued by hand.

The honest limit: schedules are in-process timers. They need Workbench running. They are not a cloud cron, and they should not be sold as one.

Durability

A queue is only durable if the process is.

Workbench uses a detached host that owns the PTYs. Closing the window does not kill a running agent; reopening reattaches to the same terminal with its scrollback and alternate-screen state. Sleep a session to stop the process while keeping the checkout and resume token; wake it to continue where the harness supports it.

Projects, sessions, worktrees, tasks, and schedules live in local SQLite. There is no hosted service behind the queue. That is a deliberate trade: the state is yours, and it is on your machine.

It also means the queue is not a cloud service. If the machine is off, the queue is off. No hosted control plane, no remote copy of your work, no vendor holding the state.

The queue and review capacity

The queue makes review load visible. Every completed task is a diff waiting for a decision. If the queue is always full and the review is always behind, the problem is not the agent count; it is the review capacity.

A queue with four slots and one reviewer is a one-reviewer system. Cap work in progress to the review capacity, not to the machine's capacity. The queue helps because it shows you the number instead of hiding it in a pile of tabs.

The queue is a mirror. If it is always full, it is showing you where the constraint is, not creating it.

How Workbench implements it

Workbench puts the queue in the sidebar, across projects. Tasks have explicit states, a 1–4 slot limit, retries as new attempts, and schedules that create ordinary queued tasks. Each task runs in a session with its own worktree. Review happens in the checkout where the agent worked, and the review decision is separate from process exit.

Mira reads the real queue and surfaces review-ready work, approvals, failures, and waiting tasks. She has no shell and cannot approve, merge, push, or edit code. The queue tells you what needs you; it does not decide for you.

The limits stay visible: tasks are supervised, not autonomous; a permission prompt still waits for a person; schedules need Workbench running. A queue that hides its limits is not a control surface.

Monday checklist

  • Move one recurring workflow from a terminal tab into a task.
  • Start with two slots, not four.
  • Write the instruction, the done condition, and the out-of-scope list before dispatching.
  • Treat a retry as a new attempt; inspect the failed one first.
  • Put recurring work in the same queue.
  • Cap work in progress to review capacity.

The queue is not a faster terminal. It is a different unit of work.