Agents SDK adds OpenCode 2.0 support via experimental OpenCodeHarness
The Agents SDK now supports running OpenCode 2.0 on Cloudflare through the experimental OpenCodeHarness, enabling session storage in SQLite and Lifecycle jobs for resuming interrupted work. Custom tools, remote MCP servers, and skills can extend the harness while connecting to Workers AI.
The Agents SDK now supports OpenCode 2.0 ↗︎ through the experimental OpenCodeHarness. Run OpenCode inside a plain Durable Object, with sessions stored in SQLite and Lifecycle jobs that wake interrupted work after eviction.
The agents/models/opencode provider connects OpenCode to Workers AI through the AI binding. OpenCode plugins extend the harness with custom tools, remote MCP servers, and skills. Refer to OpenCode's Cloudflare SDK documentation ↗︎ for the embedded host API.
Install Agents SDK 0.28.0 or later with the OpenCode packages:
npmyarnpnpmbunnpm i agents@latest @opencode/sdk@2 @opencode/plugin@2yarn add agents@latest @opencode/sdk@2 @opencode/plugin@2pnpm add agents@latest @opencode/sdk@2 @opencode/plugin@2bun add agents@latest @opencode/sdk@2 @opencode/plugin@2
Create a harness and install a Lifecycle on your Durable Object:
import { DurableObject } from "cloudflare:workers";
import { Lifecycle } from "agents/lifecycle";
import { OpenCodeWorkerd } from "@opencode/sdk/workerd";
import { OpenCodeHarness } from "agents/harness/opencode";
import { createAI } from "agents/models/opencode";
import workerTools from "./worker-tools";
export class Assistant extends DurableObject {
ai = createAI({ binding: this.env.AI });
harness = new OpenCodeHarness({
opencode: ({ storage }) =>
OpenCodeWorkerd.create({
storage,
models: { fetch: false },
plugins: [this.ai.plugin, workerTools],
}),
defaults: {
model: this.ai("@cf/moonshotai/kimi-k2.7-code", {
reasoningEffort: "low",
}),
agent: "build",
},
});
lifecycle = Lifecycle.install(this).use(this.harness);
async ask(prompt) {
const { status, text, reason } = await this.harness.prompt(prompt);
return { status, text, reason };
}
}import { DurableObject } from "cloudflare:workers";
import { Lifecycle } from "agents/lifecycle";
import { OpenCodeWorkerd } from "@opencode/sdk/workerd";
import { OpenCodeHarness } from "agents/harness/opencode";
import { createAI } from "agents/models/opencode";
import workerTools from "./worker-tools";
export class Assistant extends DurableObject<Env> {
ai = createAI({ binding: this.env.AI });
harness = new OpenCodeHarness({
opencode: ({ storage }) =>
OpenCodeWorkerd.create({
storage,
models: { fetch: false },
plugins: [this.ai.plugin, workerTools],
}),
defaults: {
model: this.ai("@cf/moonshotai/kimi-k2.7-code", {
reasoningEffort: "low",
}),
agent: "build",
},
});
lifecycle = Lifecycle.install(this).use(this.harness);
async ask(prompt: string) {
const { status, text, reason } = await this.harness.prompt(prompt);
return { status, text, reason };
}
}
The OpenCode harness guide includes the workerTools plugin, Wrangler configuration, and session APIs. The working example ↗︎ adds a browser UI, WebSocket streaming, and persistent note tools.
Source: original entry ↗
More from Cloudflare
Follow Cloudflare to get its new changes in your feed and email digest.
Persistent browser tool in Agents SDK with tabs and logins
The Cloudflare Agents SDK now includes a browserTool that allows agents to maintain a persistent browser session across multiple turns, preserving tabs, cookies, and login sessions. The browser remains alive even when the Durable Object hibernates, with a 10-minute idle timeout before creating a fresh session.
Cloudflare API MCP server sends Workers Issues as MCP Events
The Cloudflare API MCP server now exposes Workers Issues as MCP Events through webhook subscriptions, allowing agents to receive real-time notifications when production failures are detected without polling. Clients can subscribe to cloudflare.alert.workers_observability_real_time_issue scoped to an account or individual Worker.
Web Analytics: Deeper Core Web Vitals Diagnostics with LCP & INP Sub-Part Metrics
Real User Monitoring in Web Analytics now breaks down Largest Contentful Paint (LCP) and Interaction to Next Paint (INP) into their constituent phases, plus splits connection time into TCP and TLS components. These sub-part metrics are available in the dashboard and queryable through the GraphQL Analytics API to help identify which specific area is impacting page performance.