Files
captoys/docs/good-fences-slides.md
dckcandClaude Opus 5.5 9c3eaa9819 capsite/docs: Good Fences slides as presented
Dan's edits in HackMD, with image links pointed back at the PNGs beside
the deck. cookie-rotation-wiring.png comes along from the
webapp-cookie-rotation branch so the deck's images all resolve on main.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 14:04:39 -05:00

8.1 KiB

title, type, slideOptions
title type slideOptions
Good Fences Make Good Agents slide
transition center
slide false
<style> .reveal h1 { font-size: 1.8em; } .reveal h2 { font-size: 1.2em; } .reveal table { font-size: 0.6em; } .reveal ul { font-size: 0.7em; } .reveal pre { font-size: 0.45em; } </style>

Good Fences Make Good Agents

with apologies to Robert Frost

Dan Connolly · Oct 2026


I bookmark on diigo all week…

…and since Dec 2016 I've wanted them on my blog: madmode-blog#23


🎉 Monday's issue drafts itself

tada-potluck-w40

One click on potluck's EmDash dashboard; I cut, comment, and publish.

the Loom


POLA IO: diigo-cache gets limited fetch

  • makeWebApp().joinpath('diigo.com/api').withHeaders({cookie})

fluent builder API narrows

  • makeWebApp().joinpath('diigo.com/api').withHeaders({cookie})

  • ✨ diigo-week gets only read-only viewer: h-feed of public items

  • ✨ the cache id is kept in my password manager

  • ⏳ frozen { cookie }

    • fresh cookie needs a new access and a new cache


  • the cookie lives in Alice's store; access reads a read-only facet at every send
  • Mallory, holding the instance id, can use the cookie but can't rotate it

It's one piece of a toybox

story source sink trigger
S1 weekly roundup diigo, public only madmode draft weekly, human edits
S2 album to album one Google Photos album one Amazon folder each insert, nobody watching
S3 drag to archive.org Google Photos archive.org drag-and-drop

Recurring needs: narrowed capabilities and confined generated code.


The toy version: lend a mower

client.chat.completions.create({
  messages: [{
    role: 'user',
    content: 'you can use this mower for the weekend',
    things: { mower },
    about: { mower: { ts: 'type Mower { start(), push(), turn(), stop() }' }}
  }],
});
  • the neighbor writes code; a tenant runs it in a dynamic worker, endowed with only mower
  • I lend a governed mower: never more than 100 yards (10 cells) from where it started

The fence

sequenceDiagram
  participant T as tenant
  participant G as governed mower
  participant M as mower DO
  T->>G: push()
  G->>M: push()
  T->>G: push()
  G->>M: push()
  T->>G: push()
  G-->>T: throws 'fence: 2 cells from start'

⏳ _no governor code; just design: (lend-the-mower)


✨ The model writes code to mow

gpt-oss-120b on Workers AI, given about.mower and the story; the test reads the code it writes:

async (env) => {
  const { mower } = env;
  mower.start(); // cuts the starting cell
  for (let c = 0; c < cols; c++) {
    for (let i = 0; i < rows - 1; i++) {
      mower.push(); // cut next cell
    }
    ...
  }
  await mower.stop(); // wait for the whole batch to finish

✨ no await per call: promise pipelining, after one lamp example in the prompt


🪄 A little tipsy

    if (c < cols - 1) {
      calls.push(env.mower.turn());   // turn right
      calls.push(env.mower.push());   // step into next column
      calls.push(env.mower.turn());   // turn right again (now facing opposite way)
    }
  • going north: right, step east, right → facing south ✅
  • going south: right, step west, right → facing north 🐛
  • run, it would mow two columns, back and forth: "mowed 2401 cells"

🙌 Then: Project Think

ours Project Think
the neighbor's harness a Think agent: a DO with sessions, model, prompt, tools
code-mode.ts, about @cloudflare/codemode: the model writes code against types
tenants in dynamic workers DynamicWorkerExecutor, globalOutbound: null

"no ambient authority; capabilities granted explicitly via bindings"


✅ Green

⬜⬜⬜⬜⬜⬜⬜⬜
⬜🟩🟩🟩🟩🟩🟩⬜
⬜🟩⬜⬜⬜⬜🟩⬜
⬜🟩⬜⬜⬜⬜🟩⬜
⬜🟩⬜⬜⬜⬜🟩⬜
⬜🟩⬜⬜⬜⬜🟩⬜
⬜🟩⬜⬜⬜⬜🟩⬜
⬜🟩⬜⬜⬜⬜🟩⬜
⬜🟩⬜⬜⬜⬜🟩⬜
⬜🟩⬜⬜⬜⬜🟩⬜
⬜🟩⬜⬜⬜⬜🟩⬜
⬜🟩🟩🟩🟩🟩🟩⬜
⬜⬜⬜⬜⬜⬜⬜⬜

model → generated code → sandbox → mower: 36 calls, 30 cells


🧰 …with ceremony

The mower, as a codemode connector:

protected tools(): ConnectorTools {
  const mower = this.#mower;
  return {
    start: { description: "put the mower down, facing north, and cut the cell under it", execute: () => mower.start() },
    push: { description: "move forward one cell, cutting the cell it enters", execute: () => mower.push() },
    turn: { description: "turn right 90 degrees, in place", execute: () => mower.turn() },
    stop: { description: "park the mower", execute: () => mower.stop() },
  };
}

What the model ran, 7 execute calls:

await codemode.search('mower')
await state.readdir({ path: '/' })
await codemode.search('lawn')
await codemode.describe('mower.start')
await codemode.describe('mower.push')
await codemode.describe('mower.turn')
await mower.start({}); for (...) await mower.push({}); ...

🧱 Not methods on objects

Code Mode turns tools into a TypeScript API.

  • JSON in, JSON out: no reference goes in, no object comes back
  • so a neighbor can't hand what it holds to the next neighbor

One floor down, Workers RPC and Cap'n Web do pass references and pipeline calls.


🧱 Identity, in two halves

durable passable
Durable Object id ✅ ❌ a string plus a binding the receiver must already hold
Workers RPC / Cap'n Web stub ❌ dies with its request or session ✅
Endo / OCapN reference ✅ ✅

durable, passable object identity. I've been using endo for so long that it just feels like air to me.


🧱 Where it bites

  • S2, album to album: nobody watching, so no session to keep a stub alive
  • a scavenger hunt: a kid buys a Pete Rose card from the shopkeeper → it admits him to the clubhouse → Sam's telescope there reads a QR code a mile away → step 7 → he wins a bicycle
    • every hop is a reference, held for years
    • is the card genuine? the clubhouse has to ask its issuer

The turn: Cloudflare as a netlayer

OCapN on top: sturdyrefs for durability, live refs within a session, third-party handoffs.

their technique ours, on references
code mode against generated types code against about for the objects it holds
search / describe over many tools a petname directory the model can browse
saved snippets tenant code exported as an entrypoint, handed on
runFiber / stash vat persistence
sub-agents as DO facets tenants as child vats

Still load-bearing: Worker Loader, Durable Objects and facets, Workers RPC, Cap'n Web, Workers AI.


🧮 Recap +

✅ the weekly roundup drafts in one click ✨ webkeys in a password field; a read-only facet for the plugin ✨ model-written code pipelines, in a confined dynamic worker 🙌 Project Think: a green spike in an evening


🧮 Recap -

⏳ nothing deployed; the governor not built 🪄 tipsy tenants: always turn right 🧰 codemode ceremony: { description, execute }, search, describe 🧱 no durable, passable references: an OCapN layer to build


Sources