Skip to content

OpenCode integration

Sandbox Loom can use OpenCode as an opt-in coding-agent provider. OpenCode supplies the interactive agent session and model/provider selection; Sandbox Loom continues to own policy authorization, workspace boundaries, approvals, quality gates, evidence, implementation status, and Git commits.

Generate the project harness

Declare the provider in the high-level project brief:

harness:
  template: rust-binary
  coding_agent:
    provider: opencode
    executable: opencode
    agent: build
    model: provider/model

After intake normalization and harness approval, harness generate creates the optional .sandbox-loom/.opencode/ configuration, roles, and command. Review these files as proposed project configuration. They cannot grant capabilities or move commit authority out of Sandbox Loom.

Run locally

Use the normal workflow command after installing and authenticating OpenCode in the host environment:

bin/sandbox-loom run ./ --runtime local --approve

Provider credentials must remain in the external OpenCode credential store or environment. Do not put them in project-brief.yml, workflow YAML, prompts, .opencode/, evidence, or Git.

OCI execution

Prepare a rootfs containing the OpenCode executable, its required Bun/Node runtime, project quality-gate executables, and libraries. Do not copy provider credentials into the rootfs. Declare additional required rootfs commands under the generated manifest's oci.required_commands and run the preflight before starting the container:

bin/sandbox-loom rootfs prepare --project ./ --output ./.sandbox-loom/rootfs
bin/sandbox-loom run ./ --runtime oci --backend runc \
  --rootfs "$PWD/.sandbox-loom/rootfs" --approve

Rootless runc or Youki namespace/cgroup failures are host readiness failures; preserve their evidence and resolve the host prerequisite before retrying.

Resume and approvals

OpenCode provider limits, disconnects, cancellation, and timeouts are recorded as explicit failed or resumable outcomes. Reconcile the Sandbox Loom implementation ledger and the OpenCode session identity before resuming. Never create a second session for a slice that may still be active.

Permission requests are mapped from Sandbox Loom decisions. DENY remains denied, BROKERED and ESCALATE become approval requests, and OpenCode's saved permissions cannot override the Sandbox Loom policy. A successful provider exit does not bypass quality gates or the approval-required commit task.

Deterministic acceptance fixtures

The repository keeps provider-independent fixtures under tests/fixtures/opencode/. Run the acceptance coverage with:

bundle exec ruby -Itests tests/integration/opencode_acceptance_test.rb