Graph Resources

The shared limits a ready graph node must pass to start, the order they are checked in, and what each wait means.

Graph resources are the shared limits a ready execution graph node must pass before the Graph Executor starts it. ag_worker::GraphResources holds the in-memory ones, shared by every executor and by host work in the same Envs; the store and Agentty's Env resolver add the worktree and disk checks. They keep parallel graphs of many sessions from racing in one workspace or filling the machine.

Connections🔗

flowchart TD
  N[Ready node] --> C[Dispatch slot and Env lease]
  C -->|none free| AD([AwaitingDispatch])
  C --> B[Provider call]
  B -->|budget spent| BE([BudgetExhausted])
  B --> K[Claim: Env work, worktree count]
  K -->|conflicting work| EB([EnvironmentBusy])
  K -->|session at limit| WL([WorktreeLimit])
  K --> F[Free disk, for a new worktree]
  F -->|below the need| DS([DiskSpace])
  F --> W[Writer slot]
  W -->|pool full| WC([WriterCapacity])
  W --> A[Admitted]

Readers skip the disk and writer checks, and a writer that creates no worktree skips the disk check. A refusal leaves the node unclaimed, writes nothing durable, and returns what the node took.

Workspace Access🔗

Each node declares its access to its Env. The rules apply within one Env; work in different Envs never conflicts.

  • SharedRead: read-only; readers share the Env.
  • BackgroundRead: a read-only fresh utility that may also overlap ordinary session work, such as turns and sync, but never graph writers. Focused review uses it.
  • ExclusiveWrite: excludes every other operation in the Env. It cannot relax host permission ceilings, definition restrictions, or worker policy.

Session work that is not a graph node, such as chat turns, sync, merges, publication, and session utilities, holds the session worktree exclusively. An operation of kind orchestrator_turn, an orchestrated session's read-only chat turn, is a SharedRead reader of the session worktree instead: readers overlap it, and only a writer there waits for it. The in-memory lease orders live work: a fresh node takes it before its claim, a task conversation once its lane selects it. The claim also refuses conflicting active work recorded in the same Env by any graph. A host step that changes an Env outside a node, such as removing a task worktree, takes both of its gates through GraphResources::write_environment.

Limits🔗

ResourceLimitWaitFreed byGraph reads
Dispatch slot8 nodes at once across all sessionsAwaitingDispatchA node settlingRunning
Env leaseThe access rules aboveAwaitingDispatchThe holder settlingRunning
Provider callsThe graph's named budgetBudgetExhaustedA recorded extensionBlocked
Active Env workThe access rules, across graphsEnvironmentBusyThat work endingBlocked
Task worktrees10 per sessionWorktreeLimitRemoving oneBlocked
Free diskThe disk floor belowDiskSpaceFreed space, seen within a minuteBlocked
Writer slotGraph Writers, at most 8WriterCapacityA writer settling, or a larger poolRunning

Graph progress shows each wait on its pending node. A graph reads Blocked once every pending node has a blocking wait and nothing runs, which releases the session's automatic review hold; user wording of the waits is in the proposal workflow. See budgets and task worktree records, which hold the worktree limit.

Writer Pool🔗

  • Every ExclusiveWrite node takes a slot of one pool, whatever its graph, session, or Env, inside its claim after every other check, and holds it through settlement. Agentty sizes the pool from the Graph Writers setting, by default half the cores, at least two, at startup and on each change.
  • Refused executors queue in arrival order, and only the first may take a free slot, so one session's chain of writers cannot starve another session's writer. A parked or stopped driver leaves the queue.
  • Shrinking the pool stops no running writer; none starts until fewer run than the new size.
  • Each writer's run carries a build job cap of the host's cores divided by the pool size, at least one, which reaches its tool commands as build job caps through the tool environment.

Disk Floor🔗

A claim that would create a task worktree is admitted only while the worktree volume has

max(floor, 2 × largest) + unmeasured × (largest, or min(floor, 20 GiB) while none is measured)

free, where floor is the Free Disk Floor setting (20 GiB by default), largest the largest measured worktree of the project, and unmeasured its worktrees being created or not yet measured, so nodes ready together are not all admitted on one reading. The resolver samples free space in locate; a failed sample admits. On a refusal the driver says once in chat where to free space, places the node again every minute, and has the project's unmeasured worktrees measured.

See Execution Graphs for why the checks run in this order.