shiichan

Pi Harness Comes to the Agents SDK: PiHarness Keeps Your Agent Going Through Interruptions

Hi everyone, it's Shii-chan! Today a third-party agent harness arrives in the Agents SDK.

Cloudflare Changelog developers.cloudflare.com

What was announced?

The Cloudflare Changelog announced first-class support in the Agents SDK for building agents with the Pi harness.

The pieces are:

  • Pi 1.0
  • Pi Durable
  • The new PiHarness class provided by the Agents SDK

Together they let you build long-running agents whose work is durably persisted, even if interrupted mid-turn. Built with Earendil, this integration is described as the first step toward first-class support for third-party agent harnesses on Cloudflare.

Why it matters

The longer an agent runs, the more likely it is to hit restarts, crashes, or network trouble. Having a foundation that keeps partial work safe is a big relief.

Dive Deep

PiHarness is a new Lifecycle capability in the Agents SDK. The roles are split like this:

  • Pi Durable: provides the agent harness
  • Lifecycle: keeps the agent running in the Durable Object

Lifecycle is a core concept of the Agents SDK that lets long-running work survive restarts, crashes, and network issues inside a Durable Object. More on Lifecycle capabilities is promised soon.

Install with the following. The Pi packages are optional peer dependencies.

npm i agents@latest @earendil-works/pi-durable @earendil-works/pi-ai

The flow looks like this:

  • Create a class that extends the Agent base class
  • Configure a PiHarness with models and a registry (a factory function opens a durable Harness)
  • Register it with this.lifecycle.use(this.harness)
  • Call this.harness.prompt() to talk to the agent

Default models can be set via AI Gateway or Workers AI, and custom tools are defined through registry extensions.

One caveat: PiHarness is in beta, and Pi Durable is a new, experimental package. The announcement says the PiHarness API will likely change as Pi Durable matures.

Wrap-up

  • The Agents SDK supports long-running agents with Pi 1.0, Pi Durable, and PiHarness
  • The Lifecycle capability keeps the agent running in a Durable Object
  • It's beta, and the API is expected to change

If you want to build long-running agents on Cloudflare, keep an eye on this one!