LassoLassoDocs
Coding agent

OpenCode

Lasso can delegate the coding task to the OpenCode CLI. OpenCode runs with the built-in plan agent, so it reads your project and proposes changes without writing to it.

Install the CLI

npm install -g opencode-ai
opencode --version

Lasso detects the binary with which opencode. Install it before starting lasso dev, or restart the dev server afterwards.

Sign in

opencode auth login

Authenticate the providers you intend to use. Run opencode once in a terminal if you prefer the interactive flow.

Select it in Lasso

Open the model picker in the overlay toolbar. Lasso runs opencode models to populate the list, so every provider you have authenticated appears as OpenCode · provider/model. A small built-in list is used as a fallback if that command cannot run.

How a request runs

opencode run \
  --format json \
  --print-logs \
  --log-level INFO \
  --agent plan \
  --model anthropic/claude-sonnet-4-5
  • --agent plan keeps the agent read-only.
  • --print-logs is why OpenCode diagnostics reach Lasso; Lasso classifies them instead of showing raw output.
  • --format json streams structured events into the task activity log.

A request that has not finished within five minutes is stopped.

State folder permissions

OpenCode keeps data in three separate directories, and all three must be owned by your user. Fixing only the state folder is the most common reason a problem persists after a permission change.

ls -ld ~/.local/state ~/.local/state/opencode \
  ~/.local/share/opencode ~/.config/opencode

# every line must start with your username, not root

If any of them is owned by root, every prompt fails with The local agent cannot write to its own state folder. This usually happens after running sudo opencode once, or from an install that set up state as root.

# state (default ~/.local/state/opencode, or $XDG_STATE_HOME)
sudo chown -R $(whoami) ~/.local/state

# sessions and the model database
sudo chown -R $(whoami) ~/.local/share/opencode

# plugins, config, and node_modules
sudo chown -R $(whoami) ~/.config/opencode

Check the ownership again afterwards. Leaving ~/.config/opencode owned by root is a frequent cause of OpenCode starting and then spinning at 100% CPU without producing output, because it cannot load its own installed packages.

Other reported errors

  • Could not reach models.dev: OpenCode could not refresh its model list. Check the network or proxy it uses. This does not affect providers you have already authenticated.
  • Permission denied: usually the state folder above. Lasso reports filesystem failures as errors rather than as an Allow/Deny prompt, because approving a request cannot change file ownership.

Permission requests

When OpenCode genuinely asks for approval, Lasso pauses the task and shows the request in the overlay with Allow and Deny.

Next steps

Compare with Claude Code or Codex, or review the CLI reference.