Task Dependency Graph for Team Templates #57
Replies: 2 comments
|
test |
ADR-001: Runtime Task Cascade (complement to RFC #57)RFC #57 addresses spawn-time dependency via depends_on in templates. ADR-001 addresses runtime cascade: when a task completes, auto-unblock tasks that had it as their sole blocked_by. The GapRFC #57 Phase 2: When an agent completes, check if blocked agents can now be spawned. These are complementary - RFC #57 covers spawn-time dependency graph for agent orchestration; ADR-001 covers runtime cascade for task-level work items within a team. ADR-001 SummaryCore behavior: When Task A completes, any task B with blocked_by=[A] automatically gets status=pending if it has no other remaining blockers. Integration point: TaskWaiter.wait() - the existing poll loop already checks task status. Add _cascade_unblock() there. Config: ProposalAlign ADR-001 with RFC #57 Phase 2 (Phased Spawn Scheduler), since both need to detect agent/task completion:
Questions for Maintainers
Happy to submit a PR for ADR-001 as a follow-up to RFC #57 Phase 1 (schema + validation). |
Uh oh!
There was an error while loading. Please reload this page.
RFC: Task Dependency Graph for Team Templates
Summary
This RFC proposes adding explicit task dependency support to ClawTeam's TOML team templates, enabling the spawn scheduler to respect execution order, parallelize independent tasks, and block dependent tasks until prerequisites complete.
The change is backward-compatible: existing templates without dependency fields behave exactly as they do today.
Motivation
Right now, when a leader agent calls
clawteam spawn --team my-team, all workers are created at roughly the same time. This works well for tasks that are genuinely independent (e.g., the hedge fund template where each analyst examines a different stock). But many real-world workflows have inherent ordering constraints:Today, the leader agent handles this implicitly through its own reasoning — it knows it should probably spawn the architect first. But this ordering logic lives entirely inside the LLM's head, which means:
Making dependencies explicit in the template format solves all three problems without taking autonomy away from the leader — the leader still decides what to do, but the template can encode structural constraints that the leader shouldn't have to re-derive every time.
Proposed Design
Template Schema Changes
Add two optional fields to the
[[agents]]table:The
depends_onfield is a list of agentnamestrings within the same team. If omitted or empty, the agent has no dependencies and is spawned immediately (preserving current behavior).Spawn Scheduler
The current spawn logic creates all workers in a loop. The proposed change wraps this in a lightweight DAG scheduler:
This is essentially a topological sort with phased execution — nothing exotic. The key constraint is that it needs to hook into the existing transport layer to detect worker completion, which aligns well with the transport abstraction work planned for v0.3.
Interaction with Leader Agent
An important design question: should the leader be required to follow the DAG, or should it be advisory?
I'd argue for required by default, with an override flag. If someone took the time to encode dependencies in a template, they probably want them enforced. But for exploratory work, the leader should be able to bypass them:
Visualization (Optional, But Valuable)
Once tasks have explicit dependencies, we can trivially generate a preview:
$ clawteam preview --team fullstack-dev Task Execution Plan: Phase 0: architect Phase 1: frontend, backend (parallel) Phase 2: tester Phase 3: deployer Dependencies: architect ─┬─→ frontend ──┬─→ tester ──→ deployer └─→ backend ──┘This could be a simple CLI output — no need for a graphical UI at this stage. Just knowing the execution order before committing would be a significant UX improvement.
Prior Art
Several multi-agent frameworks have explored dependency-aware scheduling:
The common pattern across all of these: explicit dependency declaration leads to better reproducibility and debuggability. The specific mechanism varies, but the principle is consistent.
Alternatives Considered
1. Let the LLM figure it out (status quo)
This is what we do today. It works surprisingly well for simple tasks, but breaks down when:
Not proposing we remove this capability — it should remain the default for ad-hoc tasks. But templates should support something more structured.
2. Full DAG engine with conditional branching and loops
We could build a complete workflow engine with conditionals (
if agent_a.output contains "error" then skip agent_b) and loops (retry agent_c up to 3 times). This would be powerful but:3. Priority-based ordering instead of explicit dependencies
Instead of
depends_on, we could add apriorityinteger field where lower numbers run first:This is simpler but less expressive — you can't say "frontend depends on architect but NOT on backend." Priority ordering also can't express parallelism within the same priority level (do agents with priority=2 run in parallel or sequentially?). Dependencies are more explicit and avoid these ambiguities.
Implementation Plan
Phase 1: Schema + Validation (small, safe PR)
depends_onas an optional field in the Pydantic model for team templatesPhase 2: Phased Spawn Scheduler
--ignore-depsflagPhase 3: Preview Command
clawteam preview --team <name>outputs execution planOpen Questions
How should we detect agent completion? The transport layer currently supports message passing, but does it have a reliable "I'm done" signal? This might need to be addressed as part of the v0.3 transport abstraction.
What happens if a dependency fails? Options: (a) abort all downstream agents, (b) spawn them anyway with a warning, (c) let the leader decide. I'd lean toward (a) with an override flag, but this deserves discussion.
Should
depends_onsupport external dependencies? For example, "wait for this file to exist" or "wait for this API to respond." Probably out of scope for now, but worth considering for the future.I'm happy to start with a Phase 1 PR (schema + validation) if this direction makes sense. Would be great to hear thoughts from maintainers on the completion detection question in particular.
All reactions