Agent orchestration

Planning AI Agent Work With Dependency Graphs

Parallel agents help only when useful work is actually independent. A dependency graph turns a vague list of assignments into explicit prerequisites, deliverables, and integration gates. Use it to decide what can run now, what is blocked, and where your next decision will shorten delivery.

AI-assisted technical guide with linked primary sources. Examples are illustrative unless stated otherwise. How these guides are made.

Model deliverables rather than conversations

A dependency graph describes what must become available before another task can proceed. Give every node a concrete output: an agreed API contract, an implementation commit, a migration assessment, or an integrated verification result. A node named “ask the backend agent” describes communication; a node named “produce the versioned endpoint contract” describes something a downstream worker can inspect.

Keep task definition separate from execution. The same task may have several attempts, each with a different session, worktree, or failure reason. Store an immutable task identifier and graph revision, then attach attempts to it. Otherwise restarting an agent can appear to create a new dependency or erase a failed result.

Airflow’s workflow documentation distinguishes tasks and dependency relationships from task execution. You can borrow that distinction for coding work without introducing Airflow into a small local workflow. A tracked task document can be sufficient while the graph remains small.

Define exactly what an edge means

For an edge from A to B, write the reason B needs A. Is B consuming an artifact, waiting for an approval, or avoiding a shared-resource conflict? These are different constraints. A code-generation task may require an accepted schema artifact. A deployment requires authorization for a particular revision. Two tests may merely compete for the same database.

Use dependency edges for actual ordering requirements. Represent database capacity, model limits, and reviewer availability as resource constraints where possible. Turning every shared resource into a permanent ordering edge can hide useful parallelism and make the graph difficult to change.

Define success semantics explicitly. “A exited” is weaker than “A’s output passed validation.” GitHub Actions documents prerequisite jobs through needs, including how failure or skipping can prevent dependent jobs from running. Your agent runner needs an equally deliberate rule; do not assume a dependency library supplies your desired failure policy.

A worked graph for a reporting feature

Consider a hypothetical monthly reporting feature. The team needs a data contract, a query implementation, a user interface, and an integrated access-control check. The durations below are planning assumptions, not measured agent performance. They make the scheduling tradeoff visible.

Illustrative reporting-feature graph
NodeOutput and ownerPredecessorsEstimate
AAccepted response contract; integration ownerNone15 minutes
BQuery implementation and tests; backend agentA40 minutes
CUI implementation against fixtures; frontend agentA25 minutes
DMigration and access assessment; reviewerA20 minutes
EIntegrated feature and verification evidence; integration ownerB, C, D20 minutes

A must define field names, date boundaries, authorization expectations, and an example response. C can then work against those fixtures without waiting for B’s running server. B and C should use separate worktrees and own different files. D must return concrete findings that E resolves, rather than an unqualified approval.

Keep E visible. Three accepted branch outputs do not establish that the combined application works. E checks the actual integrated revision, including whether a user can obtain another tenant’s report and whether the UI interprets the response correctly.

Use the critical path to choose the next intervention

For the illustrative graph, A–B–E takes 75 minutes; A–C–E takes 60; A–D–E takes 55. Assuming immediate resource availability and accurate estimates, 75 minutes is the earliest completion implied by those dependencies. Launching extra frontend agents cannot shorten the backend path.

Calculate each node’s earliest finish as its duration plus the largest earliest finish among its predecessors. This simple calculation identifies where delay propagates. Include human review and approvals in the estimate: a five-minute decision that waits overnight dominates a nominally fast implementation.

The graph is only one constraint. If B and C share a single test environment, or one person owns both A and D, the real schedule may be longer. Do not present the dependency-only estimate as a promise. Record actual task time, waiting time, and rework separately, then revise future estimates from comparable work.

Validate cycles and missing prerequisites before launching

A cycle such as “UI waits for API, API waits for UI” is usually an unresolved contract. Introduce a small contract node that both can consume. Do not delete a dependency solely to make the scheduler proceed; identify the assumption that makes independent work valid.

Python’s graphlib.TopologicalSorter documentation defines graphs using nodes mapped to their predecessors and documents cycle detection. This illustrative validation snippet rejects unknown dependencies first, then asks the library to check ordering:

from graphlib import TopologicalSorter, CycleError

plan = {
    "contract": set(),
    "query": {"contract"},
    "ui": {"contract"},
    "assessment": {"contract"},
    "integrate": {"query", "ui", "assessment"},
}
known = set(plan)
unknown = set().union(*plan.values()) - known
if unknown:
    raise ValueError(f"Unknown predecessors: {sorted(unknown)}")
try:
    sorter = TopologicalSorter(plan)
    sorter.prepare()
except CycleError as error:
    raise ValueError("Resolve the dependency cycle before launch") from error

This is graph validation, not a production executor. It does not run agents, persist state, validate artifacts, or implement retry policy. The unknown-node check matters because an unintended dependency name should not silently become a legitimate task in your plan.

Handle runtime discoveries with graph revisions

Agents often discover a missing prerequisite. B might learn that report dates require a product decision about time zones. Pause B, create a decision node with an owner and output, and issue a new graph revision. Record which attempts used the old contract. Avoid letting an agent quietly redefine the API while C continues against obsolete fixtures.

For a fixed graph, readiness can be computed from accepted predecessor states. Graph mutation needs a separate control path: validate the revised plan, identify outputs invalidated by the change, and decide which attempts to restart. Do not mutate a frozen sorting object as though it were an editable project plan.

If B fails, C’s useful work need not disappear. Preserve its artifact while E remains blocked. If C becomes irrelevant because the feature is cancelled, cancel its remaining work deliberately. Distinguish blocked, failed, skipped, and cancelled states so the integration owner can make an informed recovery decision.

Keep execution visible while the graph stays authoritative

A graph can tell you that the backend task is required; it cannot tell you whether its terminal is waiting for your answer unless execution state is connected or inspected. Keep task IDs in session names and handoff notes so people can connect the plan to the right local work.

Purrvio’s Mac preview helps with that visibility for supported local coding-agent sessions, with the richest support for Claude Code and Codex. It reads supported session records and processes without installing agent hooks. Navigation supports Ghostty and Terminal.app; direct replies require Ghostty and Automation permission.

Purrvio does not construct dependency graphs, schedule nodes, or validate predecessor outputs. Maintain those decisions in your workflow. If finding a waiting session is your bottleneck, try the free Mac preview. It supports macOS 13+ on Apple silicon and Intel; the locally signed preview is not Apple-notarized.

Check the graph before starting another agent

  • Give every node a deliverable, acceptance rule, owner, and stable task ID.
  • Explain every edge and separate resource limits from artifact dependencies.
  • Reject unknown nodes and cycles before launching work.
  • Include integration, human decisions, and final verification as visible tasks.
  • Prioritize work that unblocks the critical path, then check actual resource capacity.
  • Version changed contracts and record which outputs need revalidation.
  • Preserve useful completed artifacts when another branch fails.

Start with a graph you can explain in one review. If each small change requires dozens of coordination messages, combine tightly coupled nodes or reduce concurrency. A useful dependency graph makes the next decision clearer; it should not become a second project that consumes the time saved by agents.

Frequently asked questions

Does every multi-agent project need a workflow engine?

No. A small tracked task graph can be enough for a few local sessions. A durable runner becomes useful when restart recovery, scheduling, permissions, and execution history require stronger guarantees.

Does a valid DAG guarantee that agents can run in parallel?

No. Acyclic dependencies establish a possible ordering. Shared databases, file ownership, capacity limits, and human review can still constrain concurrency.

What should happen when an agent discovers a new dependency?

Pause affected work, define the missing deliverable, validate a new graph revision, and identify artifacts that need revalidation. Preserve the previous plan and attempt history so the change remains explainable.

Sources and further reading

Primary references checked for this guide on 10 November 2026. Documentation can change; confirm version-specific behavior before using commands in a production workflow.

  1. Apache Airflow: Dags

    Checked the separation between task definitions, dependency relationships, and execution behavior; this guide applies the distinction to coding work.

  2. GitHub Actions: Using jobs in a workflow

    Checked prerequisite-job behavior through needs and the effects of failed or skipped dependencies.

  3. Python graphlib documentation

    Checked predecessor-map representation, TopologicalSorter preparation, cycle detection, and fixed-graph behavior.

Download Purrvio.

Free Mac preview. No account or API keys.

This locally signed preview isn’t Apple-notarized. macOS may block the first launch.

Download free preview ↗

3.2 MB ZIP · Apple silicon and Intel · macOS 13.0+

Read installation steps

One email before you go.

I’ll send a short setup note and reply if you hit a snag. No spam, unsubscribe anytime.