9f6d0d2281
- Bump root AGENTS.md header: 2026-05-14 → 2026-05-15, commit5ffbe0e24→53a740636, release v4.1.1 → v4.1.2 - Update file counts: 2034 (1337+697) → 2041 (1340+701), LOC ~292k → ~294k - Fix STRUCTURE: openclaw lives at src/openclaw/ (not src/features/); list more accurate feature modules in the parenthetical - Clarify interactive_bash gate: tmux binary on PATH via isInteractiveBashEnabled() (not 'tmux enabled') - Fix docs/reference/features.md hook counts: Tool Guard 14→16, Total base 52→54, total with team-mode 59→61 - Bump 'Generated' date on all 43 subdir AGENTS.md files to 2026-05-15 - Preserve promptAsync injection cautions verbatim (per request)
2.3 KiB
2.3 KiB
src/tools/delegate-task/ — Task Delegation Engine
Generated: 2026-05-15
OVERVIEW
49 files. The task tool implementation — delegates work to subagents via background or sync sessions. Resolves categories, models, skills, and manages both async and synchronous execution flows. 8+ built-in categories.
TWO EXECUTION MODES
| Mode | Flow | Use Case |
|---|---|---|
Background (run_in_background=true) |
Launch → BackgroundManager → poll → notify parent | Explore, librarian, parallel work |
Sync (run_in_background=false) |
Create session → send prompt → poll until idle → return result | Sequential tasks needing immediate result |
KEY FILES
| File | Purpose |
|---|---|
tools.ts |
createDelegateTask() factory — main entry point |
executor.ts |
Route to background or sync execution |
types.ts |
DelegateTaskArgs, DelegateTaskToolOptions, ToolContextWithMetadata |
category-resolver.ts |
Map category name → model + config |
subagent-resolver.ts |
Map subagent_type → agent + model |
model-selection.ts |
Model availability checking + fallback |
skill-resolver.ts |
Resolve load_skills[] → skill content for injection |
prompt-builder.ts |
Build system/user prompt with skill content, categories |
SYNC EXECUTION CHAIN
sync-task.ts → sync-session-creator.ts → sync-prompt-sender.ts → sync-session-poller.ts → sync-result-fetcher.ts
Each file handles one step. sync-continuation.ts handles session continuation (resume with task_id).
BACKGROUND EXECUTION
background-task.ts → BackgroundManager.launch() → (async polling) → background-continuation.ts
background-continuation.ts handles task_id resume for existing background tasks.
CATEGORY RESOLUTION
- Check user-defined categories (
pluginConfig.categories) - Fall back to built-in 8 categories
- Resolve model from category config
- Check model availability → fallback if unavailable
MODEL STRING PARSER
model-string-parser.ts handles "model variant" format (e.g., "gpt-5.3-codex medium" → model=gpt-5.3-codex, variant=medium).
UNSTABLE AGENT TRACKING
unstable-agent-task.ts marks tasks from categories/agents known to be unstable (e.g., free models). Enables unstableAgentBabysitter hook monitoring.