Run an OpenCode agent task
oc_taskCreate a fresh OpenCode session for an agent, send a prompt, and wait for completion. Returns final text with session id, cost, and token usage.
Instructions
Create a fresh OpenCode session for the given agent (and optional model override), send a prompt, and by default wait for completion. Returns the agent's final text plus session id, cost and token usage. If OPENCODE_FORCE_MODEL is set on the bridge, that model is always used.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"prompt": "<prompt>"
},
"name": "oc_task"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent | No | Agent id from oc_agents (e.g. build, plan, reviewer) | |
| model | No | Model override as "provider/model" or "provider/model#variant" | |
| title | No | Session title | |
| prompt | Yes | Task or question for the agent | |
| directory | No | Absolute project directory | |
| background | No | Return immediately with a session id instead of waiting | |
| timeoutSeconds | No | Max wait time in seconds (default 50, keeps calls under typical MCP client timeouts) |