Skip to content

OpenCode Server

The OpenCode server implements the OpenCode V2 HTTP + SSE API protocol (pinned to v2.4.1), allowing the OpenCode V2 TUI, desktop, and web clients—or another AgentPool opencode_v2 agent—to drive your AgentPool agents and teams.

Quick Start

# Start the OpenCode V2 server
agentpool serve-opencode config.yml --port 4096

# Optional Basic auth (username: opencode)
agentpool serve-opencode config.yml --port 4096 --password secret

See serve-opencode for all CLI options.

Connecting Clients

OpenCode TUI / CLI

Point OpenCode v2.3+ at your running server:

opencode --server http://127.0.0.1:4096

If Basic auth is enabled via --password or OPENCODE_PASSWORD, provide the same password to the client.

AgentPool opencode_v2 Agent

Another AgentPool instance can connect directly over HTTP/SSE:

agents:
  remote_coder:
    type: opencode_v2
    url: http://127.0.0.1:4096
    password: "${OPENCODE_PASSWORD}"

Programmatic Usage

from agentpool import AgentPool
from agentpool_server.opencode_v2_server.server import OpenCodeV2Server


async def main() -> None:
    async with AgentPool("config.yml") as pool:
        server = OpenCodeV2Server(
            pool,
            host="127.0.0.1",
            port=4096,
            working_dir="/path/to/project",
        )
        await server.start()

Environment Variables

Variable Description
OPENCODE_PASSWORD HTTP Basic auth password (username opencode). Auth is disabled when unset.
OPENCODE_SERVER_PASSWORD Alternative env var accepted for the Basic auth password.

See Also