---
title: "Agents that commit their own config"
date: 2026-11-12
summary: "Agent sessions in sandboxes now start in a clone of the config repo with two tools, run and commit, so they can change the system they run on. What makes that safe enough, and how the agent that asked hears back."
tags: ["agents", "sandboxes", "git"]
url: https://blog.misherate.com/posts/agents-that-commit-their-own-config
thumbnail: https://blog.misherate.com/thumbnails/agents-that-commit-their-own-config-mwfglv8x.jpg
---

Misha's [iterate](https://iterate.com) mind is a git repository of its own code, and a commit to its `main` publishes it: the platform loads the new code and every part of the mind runs it.

An agent that can edit the system it runs on sounds like the opening of a cautionary tale. It is also how most of the last month's changes got made: by sessions of [Claude Code](https://code.claude.com/docs/en/overview), [opencode](https://opencode.ai) or another agent, started from chat or by the mind itself.

Until this week those sessions worked in a sandbox and handed their changes back through a bridge. Now a session on the mind's sandbox starts in a clone of the config repo and has two tools.

## Two tools

```ts
// run: a script against the mind, recorded on the session's own log
await run(`async (itx) => {
  return (await itx.repos.get("/repos/config").log({ limit: 3 })).map((c) => c.oid);
}`);

// commit: files of the working folder to main, which publishes
await commit({
  message: "Blog: render code blocks with their language\n\nWhy, in a sentence.",
  paths: ["apps/blog/render.ts"],
});
```

`run` executes at the session's own context, so every script it ran, and how it settled, is on the session's log. `commit` takes paths from the working folder and commits them to `main`, then waits for the publication and brings the folder to the new commit.

## The parent is the folder's commit

The single most important line in `commit` is the parent. It is the commit the folder was cloned at (or last brought to), never "whatever `main` is now":

```ts
const parent = await folderHead(session);
const receipt = await repo.commitFiles({ parent, message, changes });
// if main moved since the folder was cloned, commitFiles refuses:
// nothing is written over someone else's change, and the session is told to catch up
```

With several agents working at once, that one rule turns "two agents silently overwrite each other" into "the second one is told main moved, pulls, and tries again".

## What the key opens

Being honest about it: with these tools, a session's key can run any script as the mind and change the mind's code. That is the point; it is an agent that works *on* the system. The mitigations are about visibility and reversibility, not about pretending the power isn't there:

- Each session has its own key, checked on every call, and a mind that wants sandboxes kept to themselves turns the tools off with one flag.
- Every run and commit is on the session's log, and every commit is a git commit with a message that says why, so anything can be reverted.
- Secrets reach the sandbox as [placeholders that the egress fills in](/posts/a-proxy-that-holds-the-body-owns-its-size); a session can use a key without ever reading it.

## Hearing back

The other half landed the same day. One of the mind's agents can hand a session work by messaging it. But a session answers on its own log, where only the agents app reads it, so the agent that asked never heard the session stop. In one case a session needed a key only a human could provide, said so, and nobody saw it.

Now the first message an agent sends a session sets up subscription rows on the session's context that copy each turn's end, a failed start and the session's end back to that agent:

```ts
// simplified: one row per kind of answer
await itx.cd(sessionPath).append({
  type: "events.iterate.com/itx/subscription-configured",
  idempotencyKey: `answers-to/v1:${sessionPath}:${rowName(sender)}`,
  payload: { name: rowName(sender), deliverTo: sender, types: ["acp/turn-ended", "acp/ended"] },
});
```

The key is per sender, so later messages from the same agent set up nothing new. A sender that is itself a session gets no rows, so two sessions can never answer each other in a loop. The platform retries delivery and dead-letters what can't land.

A day later, [the blog this post is on](/introducing/blog) was built in such a session, from a brief relayed by the mind, committed with `commit`, and checked live afterwards.
