delegate
Hands coding tasks to another AI agent that reads the project and writes code in its own loop, keeping your context clean. Use it for tests, refactors, error fixes, and boilerplate.
Instructions
Hand a coding task to another AI model running as a full agent via local opencode: it reads the project, explores, and writes the code in its own tool loop, none of which enters your context. Use it instead of writing the code yourself for: tests for code that already exists; a mechanical refactor (rename, signature change, import rewrite, API migration); lint/type/build errors (paste the error output); boilerplate or scaffolding (CRUD endpoints, config, schemas, adapters, fixtures); a port between languages or frameworks; the same edit repeated across 3 or more files; reading a large file or directory to answer one narrow question; the survey half of an audit. Runs inline by default and returns when done; Claude Code backgrounds calls past 2 minutes, other hosts wait. Pass background:true to get a job id at once, then poll check_delegation. Pass continue_session (returned by a previous delegation) to keep the same agent session instead of re-exploring. Name file paths in task; never paste their contents. model/directory/agent/autoApprove default from config — omit them. Review what comes back before reporting it done.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task | Yes | Self-contained instructions: the goal, the file paths to read or change, constraints, and how to check the result (e.g. which tests to run). The agent has not seen this conversation | |
| agent | No | opencode agent to use (defaults to config defaultAgent) | |
| files | No | Paths to attach to the agent's prompt (inline only; ignored with background:true). Rarely needed: the agent reads paths named in task itself | |
| model | No | provider/model, e.g. opencode/deepseek-v4.1-flash-free. Omit to use the configured default; don't raise it to a premium tier — split the task instead | |
| profile | No | Named preset from config profiles (see get_delegate_config) that sets model, agent, variant, directory and autoApprove together | |
| directory | No | Absolute path of the project to work in (defaults to config defaultDirectory, else the server's working directory) | |
| background | No | Run detached and return a job id immediately; poll check_delegation (default false) | |
| autoApprove | No | Let the agent edit files and run commands without asking (defaults to config autoApprove, true). When false nobody is there to approve, so actions that need approval can stall or be refused | |
| continue_session | No | Session id from a previous delegation's result, to continue in that agent session |