Skip to main content

OpenCode Local

The opencode_local adapter runs OpenCode locally. It supports provider/model routing, session resume, and Baton prompt composition.

Prerequisites

  • OpenCode CLI installed (opencode command available)
  • A configured OpenCode provider/model environment

Configuration Fields

FieldTypeRequiredDescription
cwdstringYesWorking directory for the agent process (absolute path; created automatically if missing when permissions allow)
modelstringNoOpenCode model id in provider/model format (defaults to openai/gpt-5.2-codex)
variantstringNoProvider-specific reasoning/profile variant passed as --variant
instructionsFilePathstringNoAbsolute path to the bundle entry file Baton prepends to the run prompt
promptTemplatestringNoPrompt used for all runs
commandstringNoCLI executable name (defaults to opencode)
extraArgsstring[]NoAdditional CLI args
envobjectNoEnvironment variables
timeoutSecnumberNoProcess timeout
graceSecnumberNoGrace period before force-kill

Session Persistence

OpenCode resumes stored sessions with --session when the saved session cwd matches the current cwd.

Instructions And Project Context

OpenCode local receives:

  • the agent bundle entry file from instructionsFilePath
  • any composed project instructions Baton generates from project conventions and governance reminders

This keeps reusable role behavior separate from project-specific context while still presenting one effective runtime prompt.

Environment Test

The environment test checks:

  • OpenCode CLI is installed and accessible
  • the configured model is valid
  • the working directory is absolute and available (auto-created if missing and permitted)
  • a live hello probe (opencode run --format json ... with prompt Respond with hello.) to verify the CLI can run