Files
oh-my-opencode/src/tools/delegate-task/AGENTS.md
T
YeonGyu-Kim f69ae16036 docs(agents): update hook counts 44→46, add hashline-edit documentation
- Update root AGENTS.md: hook count 44→46, commit fcb90d92, generated 2026-02-24
- Update src/AGENTS.md: core hooks 35→37, session hooks 21→23
- Update src/hooks/AGENTS.md: 46 hooks total, add modelFallback/noSisyphusGpt/noHephaestusNonGpt/runtimeFallback, jsonErrorRecovery moved to tool-guard (tier 2)
- Create src/tools/hashline-edit/AGENTS.md (93 lines): documents three-op model, LINE#ID format, execution pipeline
- Refresh timestamps: 2026-02-21→2026-02-24 on 28 files
- Update plugin/AGENTS.md hook composition counts

🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2026-02-25 00:02:05 +09:00

2.3 KiB

src/tools/delegate-task/ — Task Delegation Engine

Generated: 2026-02-24

OVERVIEW

41 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.

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 session_id).

BACKGROUND EXECUTION

background-task.ts → BackgroundManager.launch() → (async polling) → background-continuation.ts

background-continuation.ts handles session_id resume for existing background tasks.

CATEGORY RESOLUTION

  1. Check user-defined categories (pluginConfig.categories)
  2. Fall back to built-in 8 categories
  3. Resolve model from category config
  4. 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.