Skip to main content
Glama

Start an OpenCode run

opencode_run_start

Start or continue an OpenCode run under a configured read-only role, send a brief, and optionally target a session, forked copy, directory, or model.

Instructions

Start an OpenCode run under a role whose policy is read-only, or continue one, and send it a brief. role is a role the person configured; opencode_service_read method status lists them, and a role of the other policy starts with opencode_run_start_write. brief is the message that starts the run, 1 to 100000 characters. directory starts a new session there: an absolute path, the top level of a Git worktree, and the call's working directory when left out. session continues the session of an earlier start instead, which takes the role's agent, ruleset and model; give one of the two, not both. fork true with session starts on a copy of that session instead: the copy is set up as a continued session is, so its role may differ from the source's, and session is the copy, forked_from the source, and new true. The source must be idle and stays as it was; a start that fails after the copy was made removes the copy. model runs this role on another model than its own, written <provider>/<model> with an optional #<variant>: one opencode_service_read method models lists without a provider, or the role's own model or alternate. It is checked before anything is created or changed, and stays this role's choice on the session and its forks until another is named; another role never runs on it. Naming the model the role runs on without a choice takes the choice away, so the role follows the settings again. Left out, the role's choice on the session applies, else the role's model, else the agent's own, else the service's default: model_from says which. A session that something else moved to another model since these tools last set one stays on it (model_from moved), unless model is given or the role resolves to another model. A run is refused on a model its caller answers with (finding callers_model), however the model was resolved, unless the role's caller_model is allow: name another model. The run has no edit tools and is denied the git commands that write; it keeps its shell. The call returns once the brief is admitted and does not wait for the turn: opencode_run_read waits for it and reads the result. A session that is running is refused: a start needs it idle. The session is read back before any brief is sent, and nothing is sent when it differs from what was set up. state is running once the brief is admitted. It is unknown when its admission could not be confirmed: the brief may have been taken, so read the session before anything else, and send nothing again. note says where the operating note went: an instruction entry of the session, or the head of the brief. The call starts the service when it is not running; service_started says when it did. A call ends within the wait_seconds setting of its start, 50 seconds unless set.

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": {
      "role": "<role>",
      "brief": "<brief>"
    },
    "name": "opencode_run_start"
  }
}

Input Schema

NameRequiredDescriptionDefault
forkNoWith `session`: start on a copy of that session instead of continuing it; the session stays as it was.
roleYesThe name of a configured role, as `opencode_service_read` method `status` lists it.
briefYesThe message that starts or continues the run: 1 to 100000 characters, not blank.
modelNoThe model to run this role on instead of its own, written `<provider>/<model>` with an optional `#<variant>`: one that `opencode_service_read` method `models` lists without a provider, or the role's own model or alternate. It stays the role's choice on the session. Naming the model the role would run on anyway takes its choice away.
sessionNoThe id of a session an earlier start returned, to continue it. Not with `directory`.
directoryNoA new session: the absolute path of the top level of a Git worktree; left out, the call's working directory. Not with `session`.

Output Schema

NameRequiredDescriptionDefault
newYesTrue for a session this call created, a copy of another included, false for one it continued.
noteYesWhere the operating note went: `entry` an instruction entry, `prompt` the head of the brief.
roleYes
agentYesThe OpenCode agent the role runs.
modelYesThe model the session is on for this turn, written `<provider>/<model>`, with `#<variant>` when it has a variant.
stateYes`running` once the brief is admitted; `unknown` when its admission could not be confirmed: the brief may have been taken.
branchYesThe worktree's branch; null on a detached HEAD.
policyYes
messageNoState `unknown`: what to do.
sessionYesThe run's session: the copy, for a start on a fork.
directoryYesThe session's directory, the top level of its worktree.
model_fromYesWhere `model` comes from: `named` this call's `model`, `choice` one an earlier start named for this role, `role` the role's own, `agent` the agent's own, `default` the service's default, `moved` the model something other than these tools moved the session to, which it keeps.
forked_fromNoA start on a fork: the session that was copied, which stays as it was.
choice_droppedNoThe role's choice on the session that no longer passed the checks and was dropped, when there was one.
service_startedYesTrue when this call found no service running and started one.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior4/5

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

Annotations only say it is a non-idempotent, non-destructive, open-world write; the description adds far more: the call returns once the brief is admitted and does not wait, it auto-starts the service, it re-reads the session before sending and sends nothing on mismatch, a failed fork removes the copy, and the call ends within the `wait_seconds` setting (50s default). The `state: unknown` admission-uncertainty guidance is exactly the kind of behavioral disclosure annotations cannot carry. Minor deduction only because the model-resolution and refusal rules are dense enough to be hard to act on in one pass.

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

Conciseness3/5

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

Purpose and sibling routing are front-loaded, but the body is a very long, colon-chained wall of text with convoluted sentences (the `fork` sentence alone packs five clauses). Most content is relevant, yet the phrasing is hard to scan and the return-field details are partly redundant given the output schema.

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?

For a six-parameter mutation tool with side effects, concurrency rules, model inheritance, and failure modes, the definition covers prerequisites, exclusivity, error states, service lifecycle, and follow-up tooling. Nothing an agent needs in order to call it correctly or recover from a bad result appears to be missing.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3; the description nonetheless adds meaning the schema does not, such as the model resolution fallback chain (`model` choice, else role model, else agent model, else service default, reported by `model_from`), the `moved` case, the caller-model refusal finding, and what naming the role's own model does. It largely restates `brief`, `directory`, and `session` constraints that the schema already documents, which keeps it below 5.

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 first sentence gives a specific verb, resource, and scope: start (or continue) an OpenCode run under a `read-only` role and send it a brief. It also names the distinguishing sibling case — a role of the other policy goes through `opencode_run_start_write` — so an agent can route without opening either schema.

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?

It states when to use this tool versus `opencode_run_start_write` (policy of the role), versus `opencode_run_read` (to wait for the turn and read the result), and the mutual exclusivity of `session` and `directory` ("give one of the two, not both"). It also gives preconditions — the session must be idle, a running session is refused.

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