Skip to content

Task chaining: --after flag for sequential dependencies #29

@chanakyav

Description

@chanakyav

Support sequential task dependencies where one task waits for another to complete before starting.

Use Case

Common workflow: PR 1 -> PR 2 (based on PR 1) -> PR 3 (based on PR 2). You want to queue all three upfront and have them execute in sequence, each branching off the previous one's branch.

Proposed Design

Option A: --after flag

# Start first task
autopilot start --prompt "Add user model" 
# => task abc123

# Queue second task — starts automatically when abc123 completes
autopilot start --prompt "Add user API endpoints" --after abc123
# => task def456 (state: WAITING)

# Queue third task
autopilot start --prompt "Add user UI" --after def456

Option B: --base flag (branch off another autopilot branch)

autopilot start --prompt "Add endpoints" --base autopilot/abc123

This starts immediately but works on a branch based on the parent branch rather than main.

Behavior

  • --after <task_id> creates a task in WAITING state
  • Orchestrator polls until the dependency reaches COMPLETE
  • If dependency reaches FAILED or STOPPED, the waiting task also fails with a clear message
  • Child task branches off the parent's branch (not main)
  • After parent PR merges, child task should rebase onto main

Implementation Notes

  • New WAITING state in the state machine
  • New DB columns: depends_on_task_id, base_branch
  • Background polling or event-driven trigger when parent completes
  • Consider: what if parent's PR hasn't merged yet? Child should branch off parent's branch
  • Requires git worktrees (#TBD) for parallel execution during the transition period

Open Questions

  • Should --after auto-detect the parent's branch, or require --base explicitly?
  • What happens if the parent task is stopped? Should children be stopped too?
  • Should we support fan-out (multiple tasks depending on same parent)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions