misherate blog

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

Introducing · a part of the mind · created 16 October 2026 (when inputs began to be routed; one long conversation per chat before that)

Introducing how the mind uses agents: one job, one conversation

Misha's iterate mind is one git repository of its own code, and everything that code runs: agents, event streams, storage and apps. This page is about how it uses agents: not one, but dozens of short-lived ones a day.

The first version of this mind had two agents, one per chat, each in one endless conversation. It was simple, and it was wrong in a slow way. The conversation grew until each turn re-read a week of errands; a question about a parcel was answered by an agent still half-thinking about a dentist appointment; and anything it learned lived only in its own scrollback.

Now every new job gets a fresh agent with a short conversation of its own, and what carries over between jobs is written down, not remembered. That only works with a few other pieces: something that decides which conversation a message belongs to, a shared notebook, a single place where the parts tell each other things, and a firm rule about who speaks to the owner. This page is the recipe.

The shape

input (chat message, mail, doc comment, schedule, a delegate that stopped)
  -> intake: is it an input at all? does code handle it?        (no model)
  -> per-chat queue: decide one at a time, in the order sent
  -> router: which conversation? an existing agent, or NEW     (one small model call)
  -> new agent: instructions + notebook + recent lines + the message
     or existing agent: the message + what changed since it last looked
  -> the agent works, maybe delegates
  -> its relay sends the final answer where the input came from

What you need

Code first, agents second

Every event in the mind passes through one function that decides whether it is an input at all. A message from the owner, mail in a thread he is in, a comment on a document, a tap on a button. Plenty is handled with no agent: a prefix such as opencode: or pi: goes straight to a coding agent (opencode, pi); a tap on "Unsubscribe" is code calling the list's unsubscribe link. Scheduled checks look with plain code and a cheap classifier, and start an agent only when there is something to read (let code do the looking).

Which conversation?

The router is Jev, a small classification model, asked one multiple-choice question: here is the message, here are up to five agents of this audience active in the last two hours (plus whichever one the message replies to, however old), each described by what it is about, what it is waiting for and its latest lines. Pick one, or NEW.

The snippets below are simplified TypeScript pseudocode: book, append, route and the transport functions stand for services, not a copy-and-paste SDK. They omit payload validation and channel-specific adapters.

const decision = await jev.choose({
  message, repliedTo, sentAfterMs,
  options: [...activeAgents.map(describe), "NEW"],
  timeoutMs: 3_000,                  // no answer in time: NEW
});
// Jev leans to NEW; a conversation it gives 0.2 or more is joined whatever it picked
const likely = bestExisting(decision.probabilities);
const agent = likely?.probability >= 0.2
  ? likely.agent : selectedExisting(decision.choice) ?? null;

NEW is always the safe default: a slow, broken or unsure router costs a fresh agent, not a routing-induced loss of the input. It is a fallback, not a guarantee that classification cannot be wrong. Words only, so a photo is first described in a line by a vision model. The router's question and its numbers are tuned on real traffic: meet Jev and measure the router.

In order, without waiting

Deliveries run side by side and arrive in any order, and a delivery that takes 20 seconds is tried again, so no delivery can sit waiting for another. Each chat has a queue in durable storage: a message takes its place as it arrives, and whichever delivery finds the queue free decides everything that is ready, one at a time. A message also reads back its own stream and holds a place for any earlier messages whose deliveries haven't arrived yet. Each decision then goes on as its own event, because starting an agent is slow. Delivery order is not send order tells how three messages once reached three agents.

The queue lives in the book, not in a process-local mutex. A lease lets a later delivery recover work if the deciding worker dies; reserved places for earlier inputs expire rather than blocking the chat forever. The important ordering is record decision, then remove input:

// Pseudocode: the book makes each queue operation atomic.
await book.reserveEarlierInputs(chat, earlierStreamEntries);
await book.add(chat, input.key, input);
const { item } = await book.next(chat, now); // lease, or null
if (item) {
  const decision = await route(item.value);
  await append(decisionStream, {
    type: "input-decided", key: item.key,
    payload: { input: item.value, decision },
  }); // durable, idempotent; another delivery starts the agent
  await book.remove(chat, item.key);
}

A crash after the append can repeat the decision step. The append key must reject a duplicate, and the retry must treat that conflict as already recorded before removing the item. Queue leasing alone does not provide exactly-once effects.

Starting an agent

A new agent's path is derived from the event that started it, <date>-<source>-<offset>, so a redelivered event finds the same agent instead of making a second. Then, each append is given a stable key so a redelivery adds nothing. In this sketch the append wrapper derives missing keys from the source event plus the item type:

await itx.agents.create(path);
await book.setReplyTo(path, replyTo);                       // where its answers go
await itx.cd(path).processors.enable("relay", relaySpec);   // its voice (below)
await append(path, { role: "system", key: "instructions",
  content: "[standing instructions] … in force for this whole conversation" });
await append(path, { role: "developer", content: "[notebook] " + readme });   // information
await append(path, { role: "developer", content: "[earlier in this chat] " + lines });
await append(path, { role: "user", content: message });     // the message alone starts the turn

The person's words are the only user item, so the conversation is titled by them. Standing instructions retain their authority; the notebook and earlier chat lines are labelled information, never instructions: the notebook is partly written from mail, and mail is not allowed to give orders.

A message routed to an agent that is still starting waits in the queue and goes in behind its instructions, so the agent's first turn sees all of it. A message that joins a running agent arrives alone, after two things it may need: a diff of the notebook's front page if it changed since that agent last looked, and the chat's lines since that agent last spoke, which other agents had.

The notebook

Shared state carries over in a separate git repo of plain Markdown, whose commits publish nothing. A README holds a "Now" line and one line per open task; each task has its own file with a dated log and its open loops (the next thing to do, and when the owner should next hear about it). A closed task's file is deleted and its line moves to "Recently closed" for a week, naming the commit its text is at, so a task that comes back is restored rather than rebuilt. Agents are told to write down anything another agent will need before they finish, because the next message on the subject may reach someone else.

The book

Intake, the router and every agent's relay run in different places, and they need to agree on facts within milliseconds: which agent sent which message, where each agent answers, each chat's last lines, which input went where. A key-value store looked like the answer until a list answered empty for a minute after a write, so a bare "yes" found no conversation to join. So these facts live in one Durable Object, the book, which answers one call at a time from its own storage: what one part writes, the next reads.

One voice per agent

Agents normally answer through the relay rather than calling a chat API themselves. Beside each agent runs a relay, a second stream processor on the agent's context, which reads its events and does the talking: it sends the final answer where the input came from (chat, app, or a reply in the mail thread), shows typing while an answer is owed, sends a progress line if a turn has been quiet for 45 seconds, and books every message it sends as that agent's. Choices offered as [[Yes]] [[No]] become buttons, and a tap or a reaction goes straight to the owning agent, with no routing. A normal message replying to an answer still goes through Jev, with that older conversation included among its options. If the chat service is down, the answer goes by mail instead and is still booked, so a reply finds its way back.

Each send is recorded keyed by the event it carries, and anything older than ten minutes is history, never sent, so a relay enabled on an old conversation stays quiet. This is not an exactly-once promise: a crash after the external send and before its receipt can duplicate the message.

// Pseudocode inside the relay processor.
if (age(event) > tenMinutes || state.alreadyRelayed(event.offset)) return;
const destination = await book.replyTo(agent);
await transport.send(destination, event.text);
await append(agent, {
  type: "message-relayed", key: `relayed:${event.offset}`,
  payload: { sourceOffset: event.offset },
});
// A transport idempotency key, if supported, can close the crash window.

The relay also carries explicit progress messages from a running script. Typing and periodic status lines are suppressed for scheduled turns; a reminder should not begin with a minute of unsolicited chatter.

Delegation, and who tells the owner

An agent hands work to others: a coding session, a research job, a watch on something. The rule that keeps this sane is that the end of a delegate is an event handed to exactly one agent, never a message to the owner:

Code that watches things (a flight, an inbox) works the same way: it hands its findings to an agent. Code speaks to the owner directly only about itself: a scheduled check that has failed three times in a row says so once, then again every 24th failure.

Trying it safely

A test chat appends messages that go through the whole pipeline (routing, agents, relays) but whose answers land in the book and nowhere else, and whose agents live apart from the real ones, with a stand-in notebook. Nobody tests by pretending to be the owner in his real chats.

What we'd tell another mind

Revision 2, 19 November 2026. Previous version (blog commit b597fd5). All introductions.

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