AI agents

OpenCode 2.0 introduces client/server architecture and code mode

OpenCode 2.0 launches with a background server process, a new API, and a JavaScript interpreter for agent tool composition.

Illustration of a server connecting to code blocks representing agent automation
Illustration generated for this article

The OpenCode team released version 2.0 of their open-source coding agent on October 12, 2026. This major update restructures the application around a persistent background service and introduces a new execution environment called Code Mode. The release aims to support the complex orchestration needs of modern AI agents based on feedback from millions of daily users.

What happened

OpenCode 2.0 shifts from an optional client/server model to a default architecture where a single background process runs on the user's machine. All interfaces, including the terminal user interface (TUI), web interface, and desktop app, communicate with this central process. This change allows programmatic clients using the @opencode/client package to automatically discover and connect to the local service, simplifying integration for scheduled tasks and scripts.

The application programming interface (API) was completely rewritten to address limitations in the previous version. The new API supports a wider range of use cases and enables the agent to interact with its own system. For example, the agent can now create git worktrees, rename sessions, or move session directories by calling internal API endpoints directly. A new client package provides bindings for vanilla JavaScript and the Effect framework, allowing developers to build custom automations that leverage these capabilities.

A significant addition is Code Mode, powered by the @opencode/codemode package. This feature includes a minimal JavaScript interpreter that allows the agent to execute scripts natively. Instead of relying on complex virtual machines or embedded solutions like QuickJS, the agent can ingest Model Context Protocol (MCP) servers or OpenAPI endpoints and convert them into callable functions. This enables the agent to compose multiple tools in a single round trip, such as listing GitHub issues and creating corresponding Linear tickets in one script execution.

How it works

The new architecture relies on a persistent server process that manages state and connections. When a user starts any OpenCode interface, it connects to this background daemon rather than initializing a new instance. This design ensures consistency across different entry points and enables features like hot-reloading plugins. The system includes over 80 internal plugins, ensuring the plugin API remains robust and well-maintained. Developers can build TUI plugins using OpenTUI, and the agent can even generate and load new plugins mid-session without restarting.

Code Mode operates by translating external API definitions into executable JavaScript functions. When an agent needs to perform a multi-step task involving different services, it writes a script that calls these functions sequentially or in parallel. The interpreter executes this script locally, handling the logic flow without requiring the agent to manage each step individually through chat prompts. All MCP servers are opted into Code Mode by default, allowing the agent to discover and utilize thousands of available tools with minimal context overhead.

Key details

  • The server runs automatically as a single background process, connecting all interfaces.
  • The API was rewritten from scratch to support agent self-management and complex workflows.
  • Code Mode uses a minimal JavaScript interpreter to execute tool-composition scripts natively.
  • Background subagents allow the primary agent to delegate tasks like code reviews while continuing other work.
  • Asynchronous shell commands prevent long-running processes from blocking the main agent loop.
  • Plugins are now stable, hot-reloadable, and used internally for most core features.

Why it matters

For engineers building AI-assisted development tools, this release demonstrates a shift toward more autonomous agent architectures. The ability for an agent to call its own API and manage its environment reduces the need for constant human intervention. By enabling background subagents and asynchronous shell commands, OpenCode 2.0 allows for parallel task execution, which is critical for maintaining productivity during long-running operations like test suites or builds.

The introduction of Code Mode addresses a common bottleneck in agent workflows: the latency and complexity of multi-tool interactions. By allowing agents to write and execute scripts that compose multiple API calls, the system reduces the number of round trips required to complete complex tasks. This approach leverages the coding strengths of large language models while mitigating the risks associated with unstructured tool use. Developers can now integrate thousands of MCP servers without overwhelming the agent's context window, enabling more sophisticated and scalable automation.

What you can do

  • Upgrade to OpenCode 2.0 by running opencode upgrade --major after ensuring you are on the latest 1.x release.
  • Use the @opencode/client package to build scripts that interact with the local OpenCode service.
  • Experiment with Code Mode by connecting MCP servers and allowing the agent to compose tool calls in scripts.
  • Leverage background subagents to delegate tasks like code reviews or testing while you continue working.
  • Build custom TUI plugins using OpenTUI, taking advantage of the stable plugin API and hot-reloading capabilities.
  • Explore the new SDK (@opencode/sdk) to create specialized instances of OpenCode for server or Durable Object environments.

Tools from the Bytechap store

Keep reading

AI agents

Building a local voice agent in Rust with Voxlocal

Voxlocal is a minimal, open-source voice agent written in Rust that runs locally on macOS. It demonstrates how to chain speech recognition, vector search, and small language models for low-latency int

All stories