opencode_session
Create and manage OpenCode coding-agent sessions to delegate coding tasks: start a session, send prompts or shell commands, switch models, and revert changes.
Instructions
Manage OpenCode coding agent sessions. START HERE: use action 'create' to get a session ID, then 'prompt' to send coding tasks. The agent has full file access (read/write/edit/bash). Use 'model' and 'provider' params on prompt/shell/command to switch models on the fly. Actions: create, get, list, status (overall status), children, update, delete, init, abort, share, unshare, summarize, revert (undo changes, pass messageId), unrevert, prompt (send task), promptAsync (send task, return immediately), command (run agent command), shell (run shell command), diff (get code diff, optional messageId), fork (fork session at a message), todo (get session todo list), permission (respond to tool permission requests — once/always/reject). Always reuse session IDs for related work.
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": {
"action": "<action>"
},
"name": "opencode_session"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Session ID (required for most actions except create/list/status) | |
| body | No | Additional body parameters (noReply, system, tools, etc.) | |
| agent | No | Agent to use for prompt/shell (e.g. 'coder', 'build'). Defaults to the configured agent. | |
| model | No | Model ID to use (e.g. 'gpt-oss-120b', 'zai-glm-4.7', 'llama3.1-8b'). Overrides the default model for this prompt. | |
| action | Yes | ||
| content | No | Prompt content, command, or shell command | |
| provider | No | Provider ID (e.g. 'cerebras', 'opencode'). Required when specifying model. | |
| response | No | Permission response (for permission action) | |
| messageId | No | Message ID (for diff, fork, revert) | |
| permissionId | No | Permission ID (for permission action) |