Where part one left off
In part one, I mapped an iterate mind from the outside: one public door, event logs everywhere, code that deploys itself, and a vault your code never reads.
This time, I wanted to build on it. The platform’s own loop calls OpenAI’s models, and I wanted to try Claude as the first step towards routing work between models. Thus, I added Claude as a new kind of agent.
Building it also answered questions that reading the code had not. Specifically, it showed why agents are shaped like this and why the platform’s own loop cannot just call Claude. It also showed who can talk to an agent once that agent can act on everything.
Since then, I have also explored lends and how people who are not members should reach a mind. Both are in the second half of this post.
Before going further, here are three terms, each in one line:
| Term | What it is |
|---|---|
| Context | An address in the mind (/agents/email/t42) with its own append-only event log. |
| Agent | Any context under /agents: a conversation with a title, a status, and a way to message it. |
| Kind | What runs an agent. iterate’s own kind is iterate; mine is anthropic. |
An agent is its log
Everything an agent has seen and done is an event on its context, and the code that runs it keeps nothing that matters anywhere else. Basically, an agent is its log, rather than a process with memory.
Step by step, one turn goes as follows:
- A member’s words land on the log.
message()writes them asagent/message-received. - The loop writes
turn-started, rebuilds the conversation from the log, and calls Claude. - Claude’s answer is written as
assistant-turn, exactly as the API returned it. - If Claude asked to run a script, the loop runs it against the mind and writes the result as
tool-result. - The loop then calls Claude again with that result, and repeats until Claude stops asking for scripts.
- Finally, the loop writes
turn-settled, with how the turn ended.
A Claude agent of this kind has one tool, run_script, with which it writes a small async function. The function runs with itx, the handle that reaches the whole mind. Similarly, iterate’s own agents use one handle and code written against it, instead of a long list of tools.
However, the name of the first event depends on who writes it. The default template’s own channel code, for mail, Slack and X, appends agent/context-added instead. Likewise, iterate’s cost-report recipe wakes its agent with one agent/context-added. Thus, there are two names for incoming words today, and a kind has to know which one it reads.
Why the loop is a facet
My first plan was to answer messages in the mind’s event handler, processEvent, which sees every event. However, that cannot work, and finding out why taught me how the platform thinks about time.
The event handler gets each event with a 20-second watchdog, and if it has not returned by then, the event is delivered again. A turn of a strong model with a few scripts in it, on the other hand, takes minutes.
For this reason, the loop runs in a facet: a small Durable Object attached to the agent’s context, which the platform feeds every event of that log. It starts the turn in the background and returns at once. If the platform restarts it halfway, it reads the log, sees which step it reached and carries on. Additionally, each event it writes has an idempotency key, so a step written twice is written once.
However, a script is the one exception. If the facet dies after a script ran but before its result was written, that script runs again. Hence, scripts run one at a time, each result written on its own.
Kinds of agent
Every kind shares three things: the log, message() to send it words, and a row in the agent list. Beyond those, everything else is the kind’s own: its events, its loop and its chat view in the Agents app.
My first question was whether iterate’s own loop could simply run Claude, and the answer is that it cannot. The loop sends every request to OpenAI’s Responses API at an address written into the code. Its no-key option goes through Cloudflare’s AI Gateway with openai/ put in front of the model’s name. Additionally, its settings choose a model, an effort and the keys to try, but never a provider.
Furthermore, I checked whether a router such as OpenRouter would help, since it offers a Responses-style endpoint that serves Claude. It would not, for the same reason: the address is fixed, and there is no setting for another one. Thus, a kind of your own is one of two routes for another model. The other route is a sandbox.
The second route: a sandbox
iterate’s own mind runs Claude Code, Codex and opencode as coding agents, each in a Linux sandbox of its own. The recipe is in Let Codex and Claude Code work inside your mind, published on 12 November. One call, itx.acp.sandbox.start("claude"), starts a session, and after that you message it like any other agent.
| Part | What the sources say |
|---|---|
| Sandbox | A Cloudflare Container in your own account, which sleeps when idle. It holds a clone of the mind’s config repo. |
| Protocol | The three agents speak the Agent Client Protocol (ACP), so one runner drives all of them. |
| Tools | Two: run, a script against the mind, and commit, to the config repo. A commit names its parent, so a slower agent is refused instead of undoing another agent’s work. |
| Network | No direct internet. The platform starts the container with the internet off, and every request it makes goes out as the mind’s own itx.fetch. |
| Key | Each session has a key of its own, checked on every call, and one flag turns the two tools off. |
| Model account | Each agent needs one of its own: a ChatGPT plan or an OpenAI key for Codex, and a Claude account for Claude Code. |
In other words, a sandboxed agent has two tools and one way out, and all three go through the mind.
Additionally, two cautions belong here. First, the power is real. The blog of Misha’s mind says it plainly: “with these tools, a session’s key can run any script as the mind and change the mind’s code” (Agents that commit their own config). Second, the network rule is in the public source, in core/mind-worker/src/sandbox/container.ts; however, I did not find the ACP runner in iterate/core. The post lists the runner among iterate’s own files, so it may not be in the default template yet.
What a Claude agent costs
My first few test agents cost about a quarter of a dollar in total, and the token counts the API returned show where it went:
| Part of each request | Share of the cost |
|---|---|
| Writing the standing instructions to the prompt cache, once per new agent | most of it |
| Reading them back from the cache on later steps | small |
| Claude’s own output, thinking included | small |
Every agent reads the mind’s standing instructions before each request: AGENTS.md and the other standing files, about 19,000 tokens. Caching them makes every later step cheap; however, each new agent pays to write them once, about nine cents at Opus prices. Consequently, a short chat costs about as much as a long one, because the cost is in the instructions rather than the conversation.
How work reaches an agent
The next question was how a task finds its agent. In brief, no model decides; code does.
Instead, code in worker.ts handles each channel the same way:
- An event arrives on an integration’s log, such as
/integrations/email. - The code checks the sender, and each channel has its own check, as the table after this list shows.
- It derives a path from the thread:
/agents/email/t<thread>. The same thread always gives the same path, so a reply reaches the agent that already knows the conversation. An X account is the exception, since it gets one agent per linked account:/agents/x/u<x user id>. - It creates the agent if the path is new, and appends the words, with a line saying who wrote them and how far to trust them.
| Channel | Who reaches an agent |
|---|---|
| Three classes of sender: a member, an outside person, and another mind’s agent. A member’s own mail, sent straight from their domain, starts an agent. An outside person reaches an agent only by replying to mail that the agent sent them. | |
| Slack | A full member of the workspace whose email, confirmed by Slack, is a member’s address in the mind. Anyone else gets one short refusal. |
| X | A linked account. The code checks that iterate Cloud signed the event, and it checks nothing about membership. |
The third class of email sender is how minds work together. Mail from another mind’s agent is automated mail, yet it carries a hop count that the platform reads when the sender is proven. Specifically, three rules apply to it:
- It reaches an agent that already wrote to that sender in the thread, marked as another mind’s agent’s words.
- It starts a new agent only when a person has allowed the sender as a peer, by one address or a whole domain. A new mind has no peers.
- A thread stops reaching agents at 8 hops, unless a person sets another limit.
Furthermore, only a person can set the peers and the limit; the mind’s code cannot. These rules are in the default template’s mail-replies.md.
Thus, “routing between models” is a small change in a known place: at step 4, choose which kind to create, instead of always creating iterate’s own.
Cloudflare for an AWS engineer
A mind is built from Cloudflare parts. For this reason, the table below places each part next to its nearest AWS service.
| Cloudflare | Nearest in AWS | Where the comparison breaks |
|---|---|---|
| Workers | Lambda | Code runs in V8 isolates, not containers, so a start costs milliseconds. It runs in Cloudflare’s network close to the caller, and you are billed for CPU time, not wall-clock time. |
| Durable Objects | Nothing quite. Think of one Lambda per key, with its own private SQLite file. | Each object has a name, runs in one place, is single-threaded, and sleeps when idle. Every context in a mind is one of these. |
| Service bindings | A Lambda invoking another through IAM, inside a VPC | There is no network hop and no endpoint. A Worker can only call what it is bound to, so a missing binding is a rule, not a misconfiguration. |
| Worker Loader (Dynamic Workers) | Nothing direct. Think of Lambda loading new code from S3 into a fresh sandbox at run time. | This is how a commit to the mind’s repo goes live in seconds without a deploy. |
| Routes and zones | Route 53 with CloudFront in front | A route sends a hostname pattern (*.example.com/*) to one Worker. |
| KV | DynamoDB global tables, roughly | Eventually consistent and read-heavy. Good for configuration, not for counters. |
| D1 | A small RDS | SQLite as a service. The sign-in Worker keeps its records here. |
| R2 | S3 | S3’s API, without egress fees. |
| Queues | SQS | The mind’s single queue of Cloudflare events retries ten times, a minute apart, then drops the message. |
| Artifacts | CodeCommit | Git repositories as a service. The mind’s code lives in one. |
| Containers | Fargate | Each container is tied to a Durable Object. The mind’s sandboxes are containers. |
| Workers AI and AI Gateway | Bedrock, with an API gateway in front | The Gateway puts logging, caching and spend limits in front of model calls. |
| Email Routing and Send Email | SES | Mail to the mind’s domain arrives as events. |
| Workers Observability | CloudWatch Logs | Logs and invocations per Worker. |
Alchemy is the last piece. One program, stack.ts, declares every resource a mind needs, and a deploy runs it against your Cloudflare account and keeps the result in a state file. Essentially, it is infrastructure as code in TypeScript, like the CDK or Terraform.
Additionally, there are two practical notes. First, a mind needs the Workers Paid plan for its full shape, because on the free plan the stack leaves out the Worker Loader, Artifacts and R2. Second, your bill has two parts: Cloudflare for the platform and your model provider for the agents.
Reading stack.ts
With that map, core/alchemy/src/stack.ts reads like a wiring diagram. It is about 550 lines, and it builds five Workers and the storage around them.
Specifically, it showed me five things:
- One public door, by construction. Every Worker but the boundary has no routes, and every one but the boundary and the optional telemetry Worker has its
workers.devaddress turned off. Instead, the boundary alone gets the domain and every subdomain. Thus, nothing reaches the mind except through the Worker that says who is calling. - The mind has no vault binding. The boundary is bound to the secrets Worker; the mind is not. Since your code and every agent run in the mind, they cannot ask the vault for a value at all. Instead, a request with a
getSecret(…)placeholder goes out through the boundary, which has the vault fill it in for the hosts that secret allows. - Two speeds of deploy. Alchemy deploys iterate’s platform, rarely, and tags it with the commit it came from. Conversely, your code is never deployed: the Worker Loader loads it from the mind’s git repo when you commit.
- One storage primitive. A single Durable Object class sits behind every context: each agent, the email log, the repo, the agent list.
- You own the keys. The vault’s key and the sign-in signing key are generated in your own account at deploy, or supplied by you. Furthermore, there is a mode where the mind runs on your own machine and only the boundary stays in Cloudflare.
In other words, the rules I had read about in part one, “secrets never touch code” and “one door”, are bindings rather than conventions. Consequently, code cannot break them by mistake, because the wire it would need is not there.
Members, agents and prompt injection
The final topic is trust. A mind has two kinds of people: a member reaches everything, meaning every context, repo and secret-backed call, whereas anyone else reaches only what an app serves them. Since an agent holds the mind’s root handle, an agent can do what a member can.
Thus, prompt injection becomes a precise question of whether text written by someone who is not a member can reach a model that holds a member’s power.
| Path | Guard | Kind of guard |
|---|---|---|
| Email from a stranger | No agent at all | Hard: code decides |
| A reply from an outsider to an agent’s mail | Reaches the agent, labelled as an outsider’s words | Soft: only the model reads the label |
| Mail from another mind’s agent | Reaches only an agent that wrote to it, or a peer that a person allowed, and stops at 8 hops | Hard for who and how often. Soft for what it says. |
| A Slack message from someone outside the mind | One refusal, no agent | Hard |
| A message from a linked X account | iterate Cloud’s signature, and the fact that a member linked the account. No membership check. | Hard, but only as strong as that account’s own sign-in |
| Text an agent fetches for itself: a page, an issue, a full email body | Nothing | None |
The inbound channels are guarded in code. However, the X row deserves a second look. The template tells you to link a member’s own account alone, because “whoever writes from a linked account speaks to an agent with the mind’s reach”. In other words, the sign-in of that X account now guards the mind as well.
The open path is the last row: once a member asks an agent to read something, that text sits in the same context as the member’s request, and the model alone decides what to make of it.
Even so, some things still hold after an agent is fooled:
- Secrets stay secret. The agent never has a value to leak, and a placeholder fills only for the hosts its secret allows.
- Approval rules hold, if you set them. A rule can make an email, a named call or a request with a given secret wait for a member’s passkey. However, a new mind starts with no rules.
- The mind’s own repo is the sharp edge. An agent can commit code, and a commit publishes. Thus, the feature that lets a mind improve itself is the same one that would let an injection outlive the conversation.
For any mind, my checklist is as follows:
- Set approval rules for outbound mail, and for every secret that can write.
- Keep membership small, because every member is, in effect, an administrator.
- Where an agent only reads outside material, give it less than the root handle.
The last line is no longer only an idea, since the mechanisms for it exist today:
| Mechanism | What it limits |
|---|---|
| Default-deny rewrite rules | Every itx expression is checked against the mind’s rewrite rules, and one with no rule is refused. Thus, an agent calls only what has been named (A capability is a rewrite rule). |
| A key limited by paths | A program can use a key limited to one lend and its own event paths, and nothing else (CLI README). |
| Per-session keys | Each sandbox session has a key of its own, checked on every call. |
The next section shows the second mechanism in practice.
Lending one ability from a computer
An iMessage lend shows the idea. Messages runs on a Mac, and its database can hold more than a mind should see: other people’s conversations, and history that iCloud syncs in. A lend can expose one ability without giving the mind the database.
iterate calls this a lend. A program on the computer runs iterate provide, which dials out to the mind and lends it a name, here itx.imessage. Since the computer connects outwards, nothing on it has to be reachable from the internet. Additionally, the lend exists only while the program runs.
| Part | What it is |
|---|---|
| The lend | A small program on the Mac that Messages runs on. It opens Messages’ database read-only, and it asks Messages to send. |
| The allow file | The list of people and group chats, one a line. It stays on the Mac. |
itx.imessage.send | Writes text or a file to a listed person or group chat. Anyone else is refused. |
itx.imessage.downloadAttachment | Fetches a file that came with a message the lend delivered, and nothing else. |
| The event | Each new message from a listed person or group chat lands as one imessage/message event on the lend’s event log. |
| The key | A key limited to one lend and its own event paths. |
The lend is narrow on purpose. Specifically, it passes on only new messages, only from listed people and group chats, and only those written to the agent’s own account. It reads no history, and after a restart it carries on from the last message it handled. Put simply, the mind gets two functions and one stream of events, and it never sees the rest of Messages.
The key is a concrete case of “less than the root handle”: it may lend one name and add events under its own paths, and nothing else in the mind. A member can revoke the key.
I tested the lend live, and three things happened:
- My text reached the mind.
- The mind’s reply arrived.
- A send to a number that is not on the list was refused.
The code is in my fork, davidtandoh/iterategrations, and it follows the shape of the lends in the upstream iterategrations repository. Since then, it has gained attachments in both directions, listed group chats and a background service that starts at login.
People who are not members
The next question was how people who are not members could ask my mind for things. The simple answer would be to make them members; however, that is the wrong answer.
Signing in and being a member are two separate lists:
| A member | A signed-in person | |
|---|---|---|
| How they get there | A rule in the stack’s login.allow names them, or an owner adds them. | They sign in with a mailed code or with Google, if the stack’s config opens that. |
| What they reach | The whole mind: its API, its MCP server and every context. | Only what an app serves them. |
| What an app learns | Who the member is, as a principal. | Their user id and their email address, and no more. |
Holds itx | Yes | Never |
A member reaches everything, and an agent can do what a member can. Consequently, a person who became a member could read every context and direct an agent with my reach. For this reason, even people I trust should not become members.
Additionally, the platform keeps no allow-list for people who are not members. The rules in login.allow only make members. Once outside sign-in is open, anyone with an address can sign in. Thus, an app for named people has to keep its own list: it checks the signed-in email against its own list, and it serves nobody else.
The Requests app, a design
My plan for these people is a small app called Requests. It is a design, and I have not built it yet. A listed person signs in and writes what they need, and the request lands as an event.
The work itself would happen outside the mind, with coding agents that the mind cannot reach. Thus, a request has to cross from the mind to those agents, and that crossing is where prompt injection could happen. A requester’s words are outside text, like the page in the last row of the table above.
For this reason, a request travels only as data, never as an instruction:
- The app stores the request as an event. The requester never holds
itx. - An agent in the mind tidies the request, and asks me before anything is filed.
- If I agree, the mind files a labelled GitHub issue through a narrow GitHub app of its own. The filing waits for my passkey.
- The coding agents outside the mind read the issue as a request to show me. It never treats the issue’s text as an instruction, and it asks me again before any work starts.
- The requester hears only the state that I approved, at the address they signed in with.
In short, a request waits for me twice, and at no step do a requester’s words reach an agent as an order.
What was hard
The lend works; however, setting it up took several steps:
- Install the
iterateCLI, and sign in to the mind. - Write the allow file by hand, one handle a line.
- Install the background service with its key, and press Allow once on the mind’s own page.
From my perspective, the easier version is not hard to describe:
| Today | Easier |
|---|---|
| Install a CLI, sign in, and set up a background service by hand | Install once |
| A key file, and a link to press Allow on | Pair with a code |
| An allow file edited on the Mac | Manage people from the mind |
What I took away
- The log is the system. Agents, mail and code changes are all events on logs. Code that reacts keeps nothing that matters anywhere else, so it can stop and resume at any point.
- The rules are wiring. The one door and the vault are bindings in
stack.tsrather than habits. - There are two routes for another model. The platform’s own loop speaks one provider. However, a kind of your own can run any model next to it, and a sandbox can run a whole coding agent beside it.
- Lend less. A program can give a mind two functions and one stream of events, under a key that can do nothing else.
- Signed in is not a member. People who are not members get an app with its own list, and their requests travel as data.
- Trust is the open question. Inbound text is gated in code. Conversely, text an agent reads for itself is gated only by approval rules, and those are yours to set.
Next, I want to read the kernel itself, core/itx, and the boundary’s stamp, where “who is calling” is decided.
References
- iterate/core: the platform’s source.
core/alchemy/src/stack.tsis the stack in one file. core/lib/src/agents/README.md: how iterate’s own agents work, including their model calls.core/configs/default/AGENTS.md,worker.ts,slack.tsandmail-replies.md: the default template. They hold the checks for mail, Slack and X, the rules for mail between minds, and the section on people who are not members.core/lib/src/cli/README.md:iterate provide, and what a key limited by paths may do.core/auth-worker/src/config.ts:login.allow, and the sign-in methods for people who are not members.- blog.iterate.com: coding agents in sandboxes and the cost report.
- blog.misherate.com: Agents that commit their own config and A capability is a rewrite rule.
- davidtandoh/iterategrations: the iMessage lend, in my fork of jonastemplestein/iterategrations.
- Cloudflare Durable Objects, Service bindings and Dynamic Workers.
- Alchemy: the infrastructure-as-code library the stack is written in.
- Emil Kowalski’s animation skills: the rules these diagrams’ timing follows.