OpenCode deploys autonomous agents on servers to persist beyond terminal sessions
November 11, 2026 · 3 min read
Also published in Polski, Português (Brasil)
OpenCode is an open-source harness system that allows artificial intelligence agents to read files, run tests, and delegate tasks to sub-agents. The tool connects to the Model Context Protocol and supports various model providers, including GLM 5.3 and Claude Opus 5.5, without vendor lock-in. Unlike proprietary tools such as Claude Code or Codex, OpenCode operates independently of specific model authors. The primary motivation for deploying the system on a server is to maintain agent activity when a local terminal is closed or a user steps away from their computer. In a standard terminal environment, an agent session halts when the laptop lid closes or the user leaves for a break, causing the process to die or pause indefinitely. Deploying the harness on a server allows the agent to continue its work autonomously, separating the agent's lifecycle from the user's physical presence.
The architecture of OpenCode is client-server based, where a terminal user interface communicates with a local HTTP server. This server publishes an OpenAPI specification that any client can access. The command opencode serve starts this server in a headless mode, exposing an API, event streams, and a documentation endpoint. This setup allows external systems, such as continuous integration pipelines or cron jobs, to interact with the agent. It also allows the server to remain warm between launches, avoiding the cost of cold starts for the Model Context Protocol and language server protocol components. The server listens on localhost by default, but flags exist to change the hostname and port. A password can be set to enable basic HTTP authentication, with a default username of opencode.
One application of server-based OpenCode is in continuous integration and pull request reviews. The system can connect to GitHub via an application, allowing users to mention the agent in a pull request comment. The agent then starts in a GitHub Actions runner, reads the context, and may create a branch and open a pull request with a fix. Users can also configure the workflow manually by installing the command line interface globally and running the agent in standalone mode. In this mode, the command starts a private server for the specific task because no terminal user interface is present in the continuous integration environment. Another use case involves scheduling tasks using a plugin that utilizes native operating system schedulers like launchd on macOS or systemd on Linux. This allows for automated tasks, such as daily dependency audits, to run without interactive input.
A single server instance can serve multiple clients simultaneously. Integrated development environment plugins use a specific endpoint to control the interface, such as pre-filling prompts or running them remotely. Web interfaces or messaging bridges can also connect to the same process, allowing teams to work with agents centrally. When installing on a clean server, the system is installed globally via npm. The current version is under the package name opencode, while older versions remain under a different name. When running as a systemd service, administrators must explicitly set the PATH environment variable. Systemd services do not inherit the user's shell PATH, so commands like git, node, and make may fail if not included in the service configuration. The HOME variable must also be set so the system can find its configuration files.