Launch a task
python3 hooks/background-manager.py launch "<description>" "<prompt>" <droid> <parent_session_id> [autonomy_level] [model]
description: Short task label (3-5 words)
prompt: Full task instructions for the droid
droid: Droid name (e.g., executor-med, explorer)
parent_session_id: Current session ID (use "main" if unknown)
autonomy_level: low | medium (default) | high
model: Optional model override
Examples
# Search task (low autonomy - read only)
python3 hooks/background-manager.py launch "Find auth patterns" "Find all authentication implementations in src/" explorer "main" low
# Implementation task (medium autonomy - default)
python3 hooks/background-manager.py launch "Fix API errors" "Fix all validation errors in src/api/" executor-med "main" medium
# Complex task (high autonomy + model override)
python3 hooks/background-manager.py launch "Refactor auth" "Refactor auth module to support OAuth2" executor-high "main" high opus
# Multiple tasks in parallel
python3 hooks/background-manager.py launch "Fix auth" "Fix auth module errors" executor-med "main"
python3 hooks/background-manager.py launch "Fix API" "Fix API route errors" executor-med "main"
python3 hooks/background-manager.py launch "Fix UI" "Fix frontend type errors" executor-med "main"
Monitor tasks
# List all tasks with status summary (total, running, queued, completed, error)
python3 hooks/background-manager.py list
# Check specific task status (returns full task JSON)
python3 hooks/background-manager.py status <task_id>
# Get task stdout/stderr output from .out file
python3 hooks/background-manager.py output <task_id>
Complete a task manually
python3 hooks/background-manager.py complete <task_id> "<result>" [error_message]
Cleanup
# Prune stale/timed-out tasks (marks as ERROR, respects TTL of 30 min)
python3 hooks/background-manager.py prune
# Reset all tasks from memory (does NOT delete .json files)
python3 hooks/background-manager.py cleanup
Hook integration (internal - called by SubagentStop hook)
# Reads session_id from stdin JSON, finds matching task, marks complete with transcript result
python3 hooks/background-manager.py hook-complete
Files per task:
~/.factory/.omd/background-tasks/<task_id>.json - Task state (status, progress, metadata)
~/.factory/.omd/background-tasks/<task_id>.out - Stdout/stderr from droid exec
Hook: SubagentStop event calls background-manager.py hook-complete which reads transcript and auto-completes the matching task.
| Task ID |
Droid |
Status |
Result |
| [id] |
executor-med |
completed |
[summary] |
| [id] |
test-engineer |
running |
50% |
Completed
Still Running
1---2name: task-bg3description: Launch and manage background tasks for parallel droid execution using background-manager.py. Factory Droid has no native run_in_background, so this uses manual Python-based background management.4---56<Purpose>7Task-bg launches droids as background tasks for parallel execution. Factory Droid CLI does not have native `run_in_background` support, so this skill uses `background-manager.py` to manually manage background task lifecycle: launch, monitor, collect results, and cleanup.8</Purpose>910<Use_When>11- Need to run a droid task in the background while continuing other work12- User says "background", "task-bg", "run in background"13- Long-running operations (builds, test suites, large refactors)14- Multiple independent tasks that should run concurrently15- Used internally by ultrawork and ralph for parallel droid orchestration16</Use_When>1718<Do_Not_Use_When>19- Quick operations that complete in seconds -- run directly20- Tasks that need interactive feedback -- run in foreground21- For full parallel orchestration -- use `ultrawork` which manages task-bg internally22</Do_Not_Use_When>2324<What_You_MUST_Do>251. PARSE - Extract description, prompt, and droid selection262. LAUNCH - Run `python3 hooks/background-manager.py launch ...`273. TRACK - Task is recorded in `~/.factory/.omd/background-tasks/`284. MONITOR - Use `list` for summary or `status <id>` for specific task295. COLLECT - Use `output <id>` to read stdout/stderr306. REPORT - Summary of all background task outcomes31</What_You_MUST_Do>3233<What_You_MUST_NOT_Do>341. DO NOT run quick operations in background352. DO NOT forget to collect results363. DO NOT skip cleanup of completed tasks374. DO NOT use for tasks needing interactive feedback38</What_You_MUST_NOT_Do>3940<Why_Manual_Python>41Factory Droid CLI does not support `run_in_background: true` like some other platforms. Instead, we use `background-manager.py` which:42- Executes `droid exec --auto <autonomy> -- "<prompt>"` as a background process43- Tracks tasks in `~/.factory/.omd/background-tasks/` as JSON files (task state) and `.out` files (output)44- Provides CLI commands: launch, complete, status, output, list, prune, cleanup, hook-complete45- Integrates with the `SubagentStop` hook via `hook-complete` for automatic completion tracking46</Why_Manual_Python>4748<Background_Manager_CLI>4950### Launch a task51```bash52python3 hooks/background-manager.py launch "<description>" "<prompt>" <droid> <parent_session_id> [autonomy_level] [model]53```54- `description`: Short task label (3-5 words)55- `prompt`: Full task instructions for the droid56- `droid`: Droid name (e.g., executor-med, explorer)57- `parent_session_id`: Current session ID (use "main" if unknown)58- `autonomy_level`: low | medium (default) | high59- `model`: Optional model override6061### Examples62```bash63# Search task (low autonomy - read only)64python3 hooks/background-manager.py launch "Find auth patterns" "Find all authentication implementations in src/" explorer "main" low6566# Implementation task (medium autonomy - default)67python3 hooks/background-manager.py launch "Fix API errors" "Fix all validation errors in src/api/" executor-med "main" medium6869# Complex task (high autonomy + model override)70python3 hooks/background-manager.py launch "Refactor auth" "Refactor auth module to support OAuth2" executor-high "main" high opus7172# Multiple tasks in parallel73python3 hooks/background-manager.py launch "Fix auth" "Fix auth module errors" executor-med "main"74python3 hooks/background-manager.py launch "Fix API" "Fix API route errors" executor-med "main"75python3 hooks/background-manager.py launch "Fix UI" "Fix frontend type errors" executor-med "main"76```7778### Monitor tasks79```bash80# List all tasks with status summary (total, running, queued, completed, error)81python3 hooks/background-manager.py list8283# Check specific task status (returns full task JSON)84python3 hooks/background-manager.py status <task_id>8586# Get task stdout/stderr output from .out file87python3 hooks/background-manager.py output <task_id>88```8990### Complete a task manually91```bash92python3 hooks/background-manager.py complete <task_id> "<result>" [error_message]93```9495### Cleanup96```bash97# Prune stale/timed-out tasks (marks as ERROR, respects TTL of 30 min)98python3 hooks/background-manager.py prune99100# Reset all tasks from memory (does NOT delete .json files)101python3 hooks/background-manager.py cleanup102```103104### Hook integration (internal - called by SubagentStop hook)105```bash106# Reads session_id from stdin JSON, finds matching task, marks complete with transcript result107python3 hooks/background-manager.py hook-complete108```109</Background_Manager_CLI>110111<Autonomy_Levels>112| Level | Droid exec flag | Use Case |113|-------|----------------|----------|114| `low` | `--auto low` | Read-only analysis, search, documentation |115| `medium` | `--auto medium` | Most development tasks (DEFAULT) |116| `high` | `--auto high` | Complex refactoring, broad file access |117</Autonomy_Levels>118119<Available_Droids>120| Droid | Best For |121|-------|----------|122| `basic-searcher` | Simple file/pattern search |123| `explore` / `explorer` | Codebase exploration |124| `librarian` | External documentation research |125| `oracle` | Debugging and root cause analysis |126| `executor-low` | Simple changes, config edits |127| `executor-med` | Standard implementation (DEFAULT) |128| `executor-high` | Complex multi-file changes |129| `hephaestus` | Architecture-level work |130| `code-reviewer` | Code quality review |131| `security-auditor` | Security analysis |132| `test-engineer` | Test creation and coverage |133</Available_Droids>134135<Steps>1361. **Parse**: Extract description, prompt, and droid selection from user input1372. **Launch**: Run `python3 hooks/background-manager.py launch ...` via Execute tool1383. **Track**: Task is automatically recorded in `~/.factory/.omd/background-tasks/<task_id>.json`1394. **Monitor**: Use `list` for summary or `status <id>` for specific task1405. **Collect**: Use `output <id>` to read stdout/stderr from `<task_id>.out`1416. **Report**: Summary of all background task outcomes142</Steps>143144<Task_Lifecycle>145```146launch() -> RUNNING -> complete() -> COMPLETED147 -> error -> ERROR148 -> prune() -> ERROR (timeout/stale)149```150151Files per task:152- `~/.factory/.omd/background-tasks/<task_id>.json` - Task state (status, progress, metadata)153- `~/.factory/.omd/background-tasks/<task_id>.out` - Stdout/stderr from `droid exec`154155Hook: `SubagentStop` event calls `background-manager.py hook-complete` which reads transcript and auto-completes the matching task.156</Task_Lifecycle>157158<Output_Format>159## Background Tasks160161| Task ID | Droid | Status | Result |162|---------|-------|--------|--------|163| [id] | executor-med | completed | [summary] |164| [id] | test-engineer | running | 50% |165166### Completed167- [Task]: [result summary]168169### Still Running170- [Task]: [progress]171</Output_Format>