opencode_run_agent
Run an opencode agent with a prompt, model, agent, and permission mode.
Instructions
Run an opencode agent with a prompt, model, agent, and permission mode.
Launches as background job; returns job_id for polling. Set wait=true to
block until done. Unattended runs usually need auto=true - otherwise a
permission prompt stalls the run until the timeout.
Return Format
{"success": bool, "message": str, "data": {"job_id": str, "status": str, "options": dict}}
Examples
opencode_run_agent(prompt="Refactor main.py", wait=False) opencode_run_agent(prompt="Summarize README", format="json", wait=True, timeout=120) opencode_run_agent(prompt="Fix tests", model="deepseek/deepseek-flash", agent="build", auto=True) opencode_run_agent(prompt="Continue the migration", session_id="ses_123", fork=True)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| auto | No | Auto-approve permissions that are not explicitly denied (opencode --auto). Required for unattended runs that would otherwise block on an approval prompt. | |
| fork | No | Fork the session before continuing (requires session_id or continue_session) | |
| wait | No | Wait for completion (true) or return immediately with job_id (false) | |
| agent | No | Agent to use (opencode agent name, e.g. 'build' or 'plan'). Omit for the default agent | |
| files | No | File paths to attach to the message (opencode --file). Must exist on disk. | |
| model | No | Model as provider/model (e.g. 'deepseek/deepseek-flash'). Omit for opencode's default | |
| format | No | Output format: 'text' or 'json' | text |
| prompt | Yes | The prompt/message to send to the opencode agent | |
| project | No | Project directory path (optional) | |
| timeout | No | Max seconds to wait when wait=true (default 300) | |
| variant | No | Provider-specific reasoning variant, e.g. 'high', 'max', 'minimal' | |
| thinking | No | Include thinking blocks in the output | |
| session_id | No | Continue this session instead of starting a new one (opencode --session) | |
| continue_session | No | Continue the most recent session (opencode --continue); ignored when session_id is set |