misherate blog

An earlier version of this page, kept as it was (blog commit ac5aeb4). Read the current introduction.

Introducing · a part of the mind · created 20 October 2026

Introducing pi: a coding agent that lives inside the mind

Misha's iterate mind is one git repository of its own code, and everything that code runs. This page is about an agent that runs inside it, rather than beside it.

What if a coding agent didn't need a computer at all, right up until it did?

Most of what a coding agent does is read files, think, edit files and commit. None of that needs a Linux box. So pi lives in the mind itself, in a Durable Object with a SQLite database: its conversation, its files and its progress are rows. It survives a deploy halfway through a thought. A real computer starts only when a command line runs a real program, like npm test, and then the computer calls back when the line is done.

The agent loop is pi, by Earendil Works, and specifically its pi-durable package, which keeps a conversation, its tasks and its checkpoints in pluggable storage. This page is how it is wired into a mind.

What it looks like

A chat message pi: make the snake slightly faster on level 3 starts a session. pi reads the game's code, edits it, greps for the other uses of the speed constant, and commits; the mind publishes the commit, pi sees the publication succeed, and its answer comes back to the chat with what it changed. A reply to that answer goes on in the same session.

Agents have it as a capability, as they have opencode:

const name = await itx.pi.start("Rename the speed constant and update its uses", {
  notify: (await itx.whoami()).path, // my conversation is told the answer
});
await itx.pi.send(name, "Now run the tests");

What you need

Prompts are owed until answered

The session is an event stream, /pi/sessions/<name>. A prompt is a fact on it, and the processor's whole state is the list of prompts not yet answered:

reduce(state, event) {
  if (event.type === "pi/prompted") return { owed: [...state.owed, event.payload] };
  if (event.type === "pi/answered") return { owed: state.owed.filter((p) => p.input !== event.payload.input) };
}

processEvent({ state, delivery, runInBackground, append }) {
  const next = state.owed[0];
  if (!delivery.caughtUp || !next || this.running) return; // only at the head: a replay starts nothing
  this.running = next.input;
  runInBackground(async () => {
    const answered = await this.run(next);  // never throws
    this.running = null;
    await append({ type: "pi/answered", idempotencyKey: `answered:${next.input}`, payload: answered });
  });
}

runInBackground keeps the run alive past the event that started it. If the Durable Object is evicted mid-run, the platform revives it by its alarm, the prompt is still owed, and the run starts again. That restart costs almost nothing, because the prompt's input key is also pi-durable's requestId: the harness finds the submission it already made and carries on from its last checkpoint, rather than starting the conversation over. No schedule polls anything.

Files that are rows

pi never sees a disk. It sees a copy-on-write filesystem over the config repo:

class RepoFs {
  async readFile(path) {
    const mine = this.overlay.get(path);         // pi's edits, kept in SQLite
    if (mine) return mine.kind === "deleted" ? enoent(path) : mine.data;
    return this.base.read(path);                 // the repo at the session's base commit
  }
  async writeFile(path, data) { this.overlay.set(path, { kind: "file", data }); await this.save(path); }
  changes() { /* overlay minus base: exactly what a commit sends */ }
}

Reads fall through to the repo at the commit the session started from; writes land in the overlay. The diff between them is what commit sends, so there is no staging step and nothing to forget.

A shell with two halves

pi's bash tool runs just-bash, a bash written in TypeScript, over that same filesystem, inside the Durable Object. ls, grep, sed, jq and curl (through the mind's egress) all run there. So does a small git: status, diff, log, show, rev-parse and ls-files, answered from the overlay and the repo's history. Git that would change the repo (commit, push, checkout and friends) is refused; the commit tool is the only way out.

Anything else, a line that runs node, npm, tsc or a browser, goes whole to a sandbox, since a pipe can't be split across two machines:

function placeOf(line: string): "facet" | "sandbox" {
  const programs = commandWords(line).map(lookThroughWrappers); // `timeout 5 vitest` -> vitest
  return programs.every((p) => LOCAL.has(p)) ? "facet" : "sandbox";
}

A misreading only sends a line to the sandbox that didn't need it: slower, never wrong.

The sandbox, only when needed

When a line does go to the sandbox, the facet's files stay the truth, and a plain checkout on the sandbox's disk is kept in step around each line:

  1. Prepare: the checkout exists, at the session's base commit.
  2. Down: the files pi changed since the last line are written into it (the facet remembers a hash per path, so only changes move).
  3. Run: the line starts in the background, in its own process group. When it ends, the sandbox posts the exit code to a host of the mind, which keeps it as one event on the session's stream, keyed by the run, and that event ends the facet's wait.
  4. Up: the output (its last 256 KB) and whatever git status says changed come back into the overlay. Ignored files such as node_modules never move, and one over 1.5 MB stays on the sandbox.

Nothing asks the sandbox anything in between; past the line's timeout one look stops it or finds it ended. Don't wait on the sandbox: let it call back is the story of that design, and the secret it posts with can say nothing but "this run ended".

Models without a network hop

pi's model layer speaks OpenAI's Responses API through the OpenAI SDK, and that SDK accepts a fetch. So the facet hands it one that never touches the network:

const fetch = async (input, init) => {
  const body = await new Request(input, init).json();
  const answer = await itx.ai.run(`openai/${body.model}`, body, { gateway: "default" });
  return answer instanceof ReadableStream
    ? new Response(answer, { headers: { "content-type": "text/event-stream" } })
    : Response.json(answer);
};

No key in the facet; the gateway has the mind's. Sessions think at medium effort, because pi's default of "off" is sent as effort none, which the newest model refused.

Committing

commit sends the overlay's changes to the config repo's main with the session's base commit as the parent, then waits for the mind's publication event and tells pi whether it published. If main moved meanwhile, it compares each changed file at the base and at the tip. None changed there: it commits on the tip. Some did: it moves the session onto the tip, drops pi's edits to just those files, and tells pi to make them again. A three-way merge would be kinder, and is still on the list. Agents that commit their own config explains why the parent is the safety catch.

Telling whoever asked

Each prompt carries a note of facts beside the words (who wrote it, through what, where the answer goes), the same idea as opencode's. When pi/answered lands, the mind's event handler tells the answer to where the prompt came from, exactly once (it records pi/told and takes a short lease, so two deliveries can't both send), and books the message as the session's, so a reply to it goes on in that session. A prompt from an agent with notify is told in that agent's conversation instead. A read-only viewer pages through the conversation straight from the facet's SQLite, bounded and redacted, without ever opening or resuming the harness.

Getting it to load

The platform's module loader refuses a computed import(), and pi's model layer hides Node-only imports behind one. So pi's packages are bundled into one package (with code splitting on: without it, a module was inlined before the class it needed existed), the bad imports rewritten to fail up front, and the bundle pinned by commit like any dependency.

pi or opencode?

Both are delegates; how the mind uses agents is how their answers find their way back to a person.

Revision 1, 15 November 2026. The first version. All introductions.

One email per new post, at most two a day. Unsubscribe any time. Your address is kept privately and never shown.