Blog · Guide · 16 November 2026

Task Dependencies for Agents: Ready Sets and Claims

Task dependencies for agents solve a problem that human trackers mostly leave to judgment: which task can be started right now, by whom, without two workers taking the same one. A person looks at a board and knows that the API work waits for the schema. An agent given a list of forty tasks will start whichever it reads first. This guide explains the three mechanisms that make a task list safe for many agents (a ready set, an atomic claim and a wait), with the queries behind them and Forkit's tools as the working example.

What goes wrong without them

Give several agents a plain list of tasks and three failures appear.

Starting too early. An agent begins "expose tax on the API" before "add the tax column" is done. It invents a column name, or stubs the data, and the result has to be redone.

Double work. Two agents read the list in the same second, both see task 7 as free, and both do it. This is a race condition, and it gets more likely with every agent you add.

Busy waiting. An agent with nothing to do checks the list every few seconds. Each check is a model call. Fifty idle agents polling is real cost for no work.

Model task dependencies for agents

A dependency is a pair: a blocker and a blocked task. "B is blocked by A" means B cannot start until A is finished.

In Forkit:

await codemode.add_dependency({ blocker_id: a.id, blocked_id: b.id });

A task has one of four statuses: pending, in_progress, done or cancelled. Blockers stop blocking when they are done or cancelled. Cancelled counts, because a cancelled task will never finish, and leaving its dependents stuck forever helps nobody.

Forkit also records other relations between tasks (related, duplicate). Those are informational. Only blocks affects readiness.

Keep the graph shallow. A chain twenty tasks long is a sequential job with extra steps. Dependencies are most useful when they are few and the graph is wide: many independent tasks, some of which wait on one shared piece.

The ready set

The ready set is every pending task with no unfinished blocker. Graph theory calls the general idea topological order: do things only after everything they depend on. An agent does not need the whole order, only the front of it.

The query is short. Select pending tasks, excluding any that appear as the blocked side of a dependency whose blocker is not yet done or cancelled:

SELECT * FROM tasks
WHERE workspace_id = ? AND status = 'pending'
  AND id NOT IN (
    SELECT d.blocked_id FROM task_dependencies d
    JOIN tasks b ON b.id = d.blocker_id
    WHERE b.status NOT IN ('done', 'cancelled')
  );

Forkit's documentation describes its getReadyTasks() in these terms, and exposes it as the ready_tasks tool, which it calls the agent's starting point. An agent asking for ready tasks never sees one that is too early.

The point of doing this on the server: the agent does not reason about the graph. Reasoning about a dependency graph in a context window is slow and error-prone. A query is exact.

The atomic claim

Seeing a task as ready is not owning it. Between reading and writing, another agent can take it. The fix is to make "check that it is free" and "make it mine" one operation.

A conditional update does that:

UPDATE tasks
SET status = 'in_progress', claimed_by = ?
WHERE id = ? AND workspace_id = ?
  AND status = 'pending' AND claimed_by IS NULL;

The database runs this as a single step. If two agents send it at once, one update changes a row and the other changes none. The server checks how many rows changed. Zero means the race was lost.

Forkit's claimTask() is described exactly this way, and claim_task is the tool. The loser gets a null result:

const ready = await codemode.ready_tasks();
for (const t of ready) {
  const mine = await codemode.claim_task({ task_id: t.id, agent_id: 'worker-12' });
  if (mine) return mine;      // won
}
return null;                   // everything was taken; go and wait

Two details are worth copying. The claim can optionally enforce the assignee (enforce_assignee), so a task assigned to one agent is not taken by another. And the error on a failed claim is generic: it does not reveal who won, which other agents have no need to know.

This is the same technique Claude Code's agent teams use locally: Anthropic's docs say task claiming uses file locking to prevent races when teammates claim simultaneously. On a server shared by many machines, the database's conditional update plays that role.

Waiting instead of polling

When nothing is ready, the agent should sleep until something is.

Forkit's wait_for_task is a long-poll: the call stays open until a task appears or a timeout passes, up to 120 seconds. It returns how long it waited. It can filter by project and by assignee.

How it wakes: when a task is created, claimed or updated, the server writes a small wake signal, and waiting calls check for it. Signals are addressed to an assignee or to everyone, so an agent waiting for its own work is not woken by someone else's. An external system can trigger a wake as well.

The loop for a worker:

1. ready_tasks → try to claim one
2. if claimed: do the work, mark done, go to 1
3. if none: wait_for_task → go to 1

An idle worker costs one held request, not a stream of model calls.

Finishing a task

Marking a task done is what releases its dependents:

await codemode.update_task({ task_id: t.id, status: 'done' });

The next call to ready_tasks, from any agent, includes whatever that unblocked. Nobody has to notify anyone; readiness is computed from the current state each time.

Leave a note for whoever comes next. See agent handoff notes.

Sub-tasks, priorities and due dates

A few more fields help a planner shape the work. Forkit's tasks have a priority (urgent, high, medium, low), an optional assignee, an estimate, a parent task for sub-tasks, and a due date. list_tasks can filter by status, by who claimed a task, by parent and by overdue.

Use priority to order the ready set, not to express dependencies. "High priority" does not mean "first"; a blocker does.

A worked example

A planner sets up a schema change:

  1. Creates A (add column), B (API), C (UI), D (docs).
  2. Adds A blocks B, B blocks C. D has no blocker.
  3. Four workers start. ready_tasks returns A and D.
  4. Two workers race for A. One wins; the other gets null, claims D.
  5. The remaining two find nothing ready and call wait_for_task.
  6. A is marked done. B becomes ready. A waiting worker wakes and claims it.
  7. B is done; C becomes ready; and so on.

No agent reasoned about order. No task was done twice. No agent polled.

Costs to know

In Forkit, creating tasks, reading ready tasks and claiming are not charged per call. Paying is a monthly plan, and every plan includes them.

When you do not need this

Three agents on three unrelated tasks need no dependency graph. Hand each its task. The machinery pays off when tasks outnumber agents, when order matters, or when agents come and go.

Related: what is agent orchestration and MCP task tracker options compared.

Where Forkit fits

Forkit offers tasks with dependencies, a ready set, atomic claims and a wait call through one MCP endpoint, built for agents to use directly. It is free to try, and a guest identifier is enough to try it. More at forkit-mcp.com.