Skip to main content
Glama

Start an OpenCode write run

opencode_run_start_write
DestructiveIdempotent

Starts or continues an OpenCode run under a write role by sending a brief, optionally in a chosen directory, session, or fork, with an optional model override.

Instructions

Start an OpenCode run under a role whose policy is write, 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. 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 may edit files inside its worktree, and starts only while no other session is running there. 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_write"
  }
}

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.7/5.0
Behavior5/5

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

Goes far beyond the annotations, which only cover the safety profile. It discloses worktree editing scope, the single-running-session constraint, the model-resolution precedence chain including `model_from` and the `callers_model` refusal, the copy-and-cleanup semantics of `fork`, that nothing is sent if the session read-back differs, and the `wait_seconds` bound on call duration.

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 is front-loaded, but the body is one dense run-on paragraph mixing start, fork, model resolution, failure handling, and return values with no breaks. Nearly every sentence carries information, yet the lack of structure makes it hard to scan.

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 tool this complex (6 params, destructive write, forking, model overrides), the description covers refusal conditions, partial-failure behavior, and result states. An output schema exists, yet the prose still clarifies `state`, `note`, `service_started`, and `model_from`, which is more than sufficient.

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 would be 3, but the description adds real meaning beyond the schema: the precedence order for `model`, the `model_from` values including `moved`, the mutual exclusion of `session` and `directory`, and how `fork` mutates the returned identities (`forked_from`, `new`).

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?

States a specific verb and resource: start (or continue) a run under a role whose policy is `write`, and send it a brief. It immediately distinguishes itself from the sibling `opencode_run_start`, which handles the other policy, so an agent can pick between them 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?

Explicitly routes among alternatives: use `opencode_service_read` method `status` to list roles, `opencode_run_start` for a role of the other policy, and `opencode_run_read` to wait for and read the turn. It also states the refusal condition (session must be idle) and the `unknown` recovery path.

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