Skip to main content
Glama

opencode_run

Delegate a coding task to an OpenCode agent and block until it finishes or needs input. Resume the same session with your answer or permission decision.

Instructions

Delegate a coding task to OpenCode and block until it completes, errors, or needs input (a question or a permission).

  • New task: pass directory + task + agent (a new session is created). agent is REQUIRED for a new session.

  • Continuation / resume: pass session_id (+ task for a NEW turn on that session, or task is ignored when the turn is still in flight). agent is not needed to resume an in-flight turn (it is taken from the turn's durable state); pass it only when starting a fresh turn on an existing session.

  • agent: the OpenCode agent to run as root. Free string, validated dynamically against the project's live agent list (GET /agent). It MUST be a primary agent of that directory (project-specific primary agents are preferred when they fit the task; build is the generic implementation agent; plan is read-only). Subagents are rejected as root. Do not rely on the server's default_agent: always choose explicitly for a new session.

  • model: optional 'provider/model' override.

RESUME: if session_id is given and that session still has a turn in flight (busy/retry) — e.g. the controller restarted mid-turn — the prompt is NOT resubmitted: the wait loop simply resumes on the SAME turn (task and agent are ignored in that case).

The call blocks until the turn ends. While OpenCode works, NOTHING is polled — the controller watches SSE + REST internally. If OpenCode asks a question or requests a permission, the call returns state='needs_agent_input' (kind='question' or 'permission') with everything needed to decide; answer with opencode_answer / opencode_permission, which resume the SAME turn. Returns the final assistant text + diff on completion.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskYes
agentNo
modelNo
timeoutNo
directoryYes
session_idNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full disclosure burden, and it excels. It discloses the blocking semantics, that 'NOTHING is polled — the controller watches SSE + REST internally', the needs_agent_input return state with kind='question' or 'permission', the RESUME behavior where 'the prompt is NOT resubmitted' for in-flight turns, and the final output (assistant text + diff). No contradiction with annotations since none exist.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Long but every sentence earns its place for a 6-parameter stateful tool. It is front-loaded with the core blocking purpose, then uses clear scoping (RESUME: heading in caps, bulleted usage modes, bolded parameter names) that makes dense content scannable. The complexity of the state machine fully justifies the length.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 6 parameters, zero schema descriptions, and a complex state machine, the prose is remarkably complete: it covers new-task vs continuation, in-flight resume, root-agent restrictions, the question/permission return path, and the completion output. An output schema exists to carry return-value details, and the description handles everything an agent needs to invoke it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the prose must carry parameter meaning, and it does comprehensively: 'agent' gets a rich treatment (root-only, validated against live list, subagents rejected, build vs plan semantics), 'session_id' gets the full resume/in-flight nuance, 'model' is the 'provider/model' override, and 'directory'+'task' are the new-task pair. The only mild gap is 'timeout', documented only by its schema default of 3600, but this is optional and self-evident.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence states a specific verb+resource: 'Delegate a coding task to OpenCode and block until it completes, errors, or needs input.' This clearly distinguishes the tool from its siblings (opencode_answer, opencode_permission, opencode_abort, opencode_inspect, opencode_sessions), which are named as complementary follow-ups rather than alternatives to run.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit when-to-use guidance with exclusions: 'New task: pass directory + task + agent' vs. 'Continuation / resume: pass session_id', including the condition that 'task is ignored when the turn is still in flight' and that 'agent' is not needed to resume an in-flight turn. It also names the answer/permission siblings as the path for resuming a turn in needs_agent_input state. No inference is left to the agent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ArthurHtr/opencode-hermes-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server