The latest Agents SDK release adds an experimental OpenCodeHarness that lets you execute OpenCode 2.0 inside a plain Durable Object. Sessions are persisted in an embedded SQLite database and a lifecycle job can restart work that was interrupted by object eviction. For teams that already use Workers AI, this creates a single‑runtime pattern for running large‑language‑model‑driven agents on Cloudflare’s edge.
OpenCode Harness Overview
The harness is marked experimental, meaning the API surface may change and official support is limited. It wraps OpenCode’s runtime inside a Durable Object, exposing two key behaviours:
- State is stored locally in
SQLite, giving each user a lightweight session store without external dependencies. - A background lifecycle job monitors eviction events and re‑queues any in‑flight work, allowing the object to recover after Cloudflare’s automatic memory reclamation.
Because the harness runs in a plain Durable Object, it does not rely on any of the higher‑level Agent constructs such as scheduled workflows or built‑in tool runners.
Integration with Workers AI and Plugins
The provider path agents/models/opencode connects the harness to Workers AI through the AI binding. This binding forwards model calls directly to the Workers AI service, letting the OpenCode engine use the same inference endpoint as other Cloudflare AI workloads.
OpenCode plugins can be added to the harness to supply custom tools, remote MCP servers, or domain‑specific skills. The plugin model is unchanged from the standard OpenCode SDK; the only difference is that the host API is now the Cloudflare‑specific embedded interface documented in the OpenCode Cloudflare SDK guide.
Operational and Security Implications
Running an experimental harness inside a Durable Object introduces several considerations:
- Eviction handling: While the lifecycle job attempts to resume interrupted sessions, there is no guarantee of exactly‑once execution. Practitioners should design idempotent tool calls and be prepared for occasional duplicate work.
- Session isolation: Each Durable Object instance holds its own
SQLitefile. Access control must be enforced at the application layer; the harness does not provide built‑in authentication. - Prompt quotas: Workers AI enforces per‑account limits. Adding a quota check before forwarding a prompt can prevent unexpected throttling.
- Unsupported local tools: The experimental harness does not support the full set of OpenCode local tools. Any tool that requires external binaries or OS‑level access should be removed or replaced with a remote plugin.
- Versioning: The harness requires
Agents SDK 0.28.0or later together with the OpenCode packages. Upgrading the SDK may introduce breaking changes to the experimental API.
Related CloudNinjas coverage: AI engineering.
What This Means For Practitioners
Adopting the OpenCode harness gives you a low‑overhead path to run LLM‑driven agents at the edge, but you must treat it as a prototype rather than production‑grade code. Evaluate the following before committing:
- Confirm that your workload can tolerate occasional duplicate execution caused by eviction recovery.
- Implement explicit authentication and prompt‑quota checks around the
AIbinding. - Validate that all required tools are available as remote plugins, since local tool execution is not supported.
- Monitor SDK releases for changes to the experimental API and plan for migration.
When those constraints are acceptable, the OpenCode harness provides a concise architecture: a single Durable Object per user session, SQLite persistence, and direct Workers AI inference—all managed through the Agents SDK.

