How sagaryeole/ai-task-orchestrator works
Purpose and Entry Points
Task Orchestrator is an offline-first Python controller for unattended AI coding backlogs. It reads Markdown checklist tasks, invokes configured coding-agent CLIs, handles rate-limit failover, verifies changes, and marks successful tasks complete.
Primary entry points:
• Legacy/direct executable: orchestrator.py
• Installed CLI and subcommands (init, validate): src/task_orchestrator/cli.py
• Core package execution path: src/task_orchestrator/runner.py
CLI and Initialization Boundary
The CLI parses run modes such as dry-run, one-shot execution, provider/task overrides, task filtering, JSON logs, and concurrency. init scaffolds project-local backlog/config/prompt assets; validate checks readiness without invoking agents.
Relevant paths:
• src/task_orchestrator/cli.py
• task-orchestrator.config.schema.json
• task-orchestrator.config.json
The runtime is Python 3.9+ and standard-library-only; it is distributed as a package through pyproject.toml.
Configuration-Driven Provider Layer
Providers are declarative subprocess definitions: executable command, environment overlay, rate-limit output patterns, cooldown, enabled state, and optional priority. Commands receive prompts over stdin unless their command includes {{TASK}}, which inserts the generated prompt as one argv element.
Relevant paths:
• task-orchestrator.config.json
• task-orchestrator.config.copilot.json
• examples/multi-provider.json
This boundary isolates external systems: Copilot, Claude, Codex, Kilo, Ollama, or any compatible local/remote agent CLI. The orchestrator itself makes no network calls; configured CLIs own authentication and outbound API traffic.
Backlog, Prompt, and State Inputs
The runner selects unchecked GitHub-flavored checkbox items from the configured Todo file, optionally batches them, renders task text into a prompt template, and maintains resumable provider cooldown state.
Relevant paths:
• Todo.md
• prompts/task_prompt.txt
• src/task_orchestrator/runner.py
Project-local runtime outputs include state.json for cooldown persistence and logs/ for append-only text/JSONL records. Task text and provider command configuration are trusted inputs; subprocesses run without a shell.
Per-Task Control Flow
For each selected task or batch, the runner:
1. Chooses an available provider by priority or round-robin, respecting persisted cooldowns and optional forced provider selection.
2. Runs the provider synchronously with merged environment and captured combined output.
3. Detects configured rate-limit patterns; on match, persists cooldown and immediately retries the same task on another provider.
4. If all providers are cooling down, waits until the earliest expiry.
5. Uses exit status and repository change detection to reject suspicious/no-op outcomes.
6. Runs configured verification commands, then obtains manual approval or automatically accepts.
7. Marks all batch tasks complete atomically; optionally commits changes; sleeps before the next successful task.
Core implementation paths:
• src/task_orchestrator/runner.py
• orchestrator.py
• scripts/sync_todo.py
Quality and Repository Boundaries
Verification commands run in the configured working directory and have per-command timeout protection. Git is both a change-detection boundary (git status --porcelain) and an optional commit target. Failed verification, agent failure, rejection, or retry policy determines whether to retry, rotate, continue, or stop.
Relevant paths:
• src/task_orchestrator/runner.py
• task-orchestrator.config.schema.json
• README.md
Observability and Interactive Runtime Services
The system writes concise terminal status while retaining full provider, verification, and stats output in logs; optional JSONL supports local downstream processing. An optional stdlib HTTP dashboard exposes current task/provider/history state as HTML and /api/state JSON. Interactive terminal commands can pause, resume, skip, or quit cleanly.
Relevant paths:
• src/task_orchestrator/runner.py
• src/task_orchestrator/cli.py
• run_forever.sh
Cross-platform supervisor scripts support crash-restart operation on shell and PowerShell:
• run_forever.sh
• run_forever.ps1
Main entry points: runner.py Runner · cli.py Installed CLI · task-orchestrator.config.json Runtime config · Todo.md Task backlog
Components 18
Entry & Setup
- Installed CLI · Run, init, and validate subcommands.
src/task_orchestrator/cli.py - Legacy executable
orchestrator.py - Restart supervisors · Crash-restart wrappers for unattended operation.
run_forever.sh
Task Execution
- Runner · Coordinates selection, execution, retries, verification, and completion.
src/task_orchestrator/runner.py - Task selection & batching · Selects unchecked tasks and renders batch prompts.
src/task_orchestrator/runner.py - Provider scheduler · Priority or round-robin selection with cooldown failover.
src/task_orchestrator/runner.py - Verification commands · Configured commands run with per-command timeouts.
src/task_orchestrator/runner.py - Approval & completion · Accepts or rejects results, atomically checks off batches, and may commit.
src/task_orchestrator/runner.py
Project Inputs
- Runtime config · Provider, verification, task, and runtime policy.
task-orchestrator.config.json - Config schema
task-orchestrator.config.schema.json - Task backlog
Todo.md - Prompt template
prompts/task_prompt.txt
Runtime Boundaries
- Agent subprocesses · Trusted prompts are sent over stdin or as a {{TASK}} argv value.
- Cooldown state · Resumable provider rate-limit state.
- Change detection · Rejects suspicious or no-op agent outcomes.
src/task_orchestrator/runner.py - Git repository · Optional commit target after accepted work.
- Logs · Provider, verification, and statistics records.
- Dashboard & controls · Exposes state and accepts pause, resume, skip, and quit.
src/task_orchestrator/runner.py
Connections 20
- Installed CLI → Config schema: validates config
- Installed CLI → Runtime config: loads
- Installed CLI → Runner: starts
- Legacy executable → Runner: starts
- Restart supervisors → Installed CLI: restarts
- Runtime config → Runner: runtime policy
- Task backlog → Task selection & batching: unchecked tasks
- Prompt template → Task selection & batching: renders prompt
- Runner → Task selection & batching: coordinates
- Task selection & batching → Provider scheduler: selected task or batch
- Provider scheduler → Cooldown state: reads and persists
- Provider scheduler → Agent subprocesses: invokes available provider
- Agent subprocesses → Provider scheduler: output / rate limit
- Agent subprocesses → Change detection: workspace changes
- Change detection → Verification commands: changed result
- Verification commands → Approval & completion: verification result
- Approval & completion → Task backlog: atomically marks complete
- Approval & completion → Git repository: optional commit
- Runner → Logs: writes status and output
- Runner → Dashboard & controls: publishes runtime state