Skip to content

opencode

diapason.agents.opencode

OpenCodeAgent -- wraps the opencode coding agent via its headless HTTP server.

Spawns opencode serve (https://opencode.ai) and drives a session over its HTTP API, configured to use Diapason's local engine through an OpenAI-compatible provider. This keeps coding-agent work local-first: opencode handles the agentic loop / tools, Diapason supplies the model.

opencode is an external binary (install: npm i -g opencode-ai or brew install anomalyco/tap/opencode). It is not bundled; :meth:run raises a clear error if it is not on PATH.

OpenCodeAgent

Bases: BaseAgent

Agent that delegates coding tasks to a local opencode server.

The engine is used to wire opencode at an OpenAI-compatible provider so inference runs on Diapason's selected local model. agent selects opencode's built-in agent: build (full access) or plan (read-only).

close()

Dispose the opencode session/server and terminate the process.

run(input, context=None, **kwargs)

Run a coding task through opencode and return the assistant result.

is_opencode_available()

Return True if the opencode binary is on PATH.