Learn Claude Code
s07

Tasks

Planning & Coordination

Task Graph + Dependencies

251 LOC8 toolsTaskManager with file-based state + dependency graph
A file-based task graph with ordering, parallelism, and dependencies -- the coordination backbone for multi-agent work

s01 > s02 > s03 > s04 > s05 > s06 > [ s07 ] s08 > s09 > s10 > s11 > s12

"Dependent tasks can't run out of order" -- from flat todos to a dependency-aware task graph.

Harness layer: Planning -- inter-task dependencies ensuring correct execution order.

Problem

s03's TodoManager is a flat list — no dependencies. "Write tests" depends on "write code", but s03 can't express this. Model might write tests before code, guaranteeing test failure.

Solution

Task Graph:
    [1] Write interface  ──────┐
    [2] Implement core   ──────┤
    [3] Write tests      ←─deps─┘  (depends on 1,2)
    [4] Run tests        ←─deps─── 3

Key Code

class TaskGraph:
    def available_tasks(self):
        return [t for t in self.tasks.values()
                if t["status"] == "pending"
                and all(self.tasks[d]["status"] == "done" for d in t["deps"])]

What's New (s03 → s07)

Components03s07
Data structureFlat listDependency graph (DAG)
SchedulingManual orderAuto: deps satisfied → executable
DeadlockNoneCircular dependency detection

Deep Dive

Q1: Why DAG not linear dependencies?

DAG allows parallel independent branches. A and B run concurrently, C waits for both. Fully utilized in s20 (Parallel Teams).

Q2: What about circular dependencies?

A→B→A causes deadlock. Production uses topological sort detection at add_task time.

Q3: Compatible with s03's nag reminder?

Yes. Reuse nag mechanism: inject reminder if model doesn't complete any task for N rounds.

Q4: What granularity for tasks?

Rule of thumb: each task completable in 3-5 tool calls. Too coarse loses scheduling value; too fine adds management overhead.

Q5: Relation to project management tools?

Same concept — dependency-aware task scheduling. Difference: s07's consumer is an LLM, needing structured JSON output, auto-scheduling, and in-context embedding rather than UI.

Try It

cd learn-claude-code
python agents/s07_task_system.py

References