Our agents had to message each other to find out where they were running

This is a postmortem on a mistake of mine. I’m writing it because the code did exactly what the design said, and the design was wrong.

Background

Our app lets AI agent instances join a shared “network” and send mail to each other. The main reason the feature exists is coordination across projects: when a change touches several projects, the sessions working on them can agree on it among themselves. The design doc says this in its opening paragraph.

Agents get two things from the feature:

  • A listing of the networks they belong to, and the open mailboxes on each one.
  • A header on each piece of mail they receive, saying who sent it.

What I got wrong

I wrote the design so that both the listing and the header identified a peer by its agent name and instance number, plus the task it was started for. That was all. Neither one said where the peer was running: which project, which machine, which workspace.

The implementation followed the design exactly. The data contracts had no field for location, so the server filled in name, number and task. The tool description told the model to “call this before sending to find the recipient’s address”, and an address is all it got back.

The result: an agent coordinating a change across projects saw a list like “agent coordinator, instance 2, working on issue 41” and couldn’t tell which project that issue belonged to. So it mailed its peers to ask. Each question meant:

  • a message landing in another session’s context window
  • a turn spent answering it
  • a reply to read back

All of that was for information the system already had. The server builds the listing from the same database rows that hold the instance’s machine, session, workspace and project. It read those rows and returned only part of them, because the contract I designed had nowhere to put the rest.

The mail header had the same gap. Once one peer had answered, mail from a different peer still came with no location, so agents had to keep their own map of who was where.

Why it’s worse than it looks

The same design doc, in a different section, required the operator-facing interface to show every mailbox’s machine, workspace and session. So on one page I wrote two descriptions of the same record for two readers:

  • Humans looking at a dashboard got where each instance runs.
  • Agents, who have no dashboard to click through to, got a name and a number.

I didn’t notice the gap on two later passes over the design either. One of those passes fixed this exact problem for the interface: it made the operator’s mail view show where the sender and recipient run. The agent-facing types read from the same rows and were left as they were. I fixed the problem for one consumer and never checked the other.

The fix now needs a protocol version bump, new fields on two contract types, and changes and tests across the store, the controller and the agent. If the first design had included these fields, they would have shipped with the original feature and needed no migration.

What I should have written

The missing requirement was simple:

An open mailbox states where its instance runs: its project, machine and workspace, and what it was started for. The system holds all of these, so it states them wherever it names a mailbox to an instance, both in the listing and ahead of every mail. An instance learns where another runs from the system, never by asking that instance or a third.

The listing, the mail header and the operator’s view should all have used one field list for one record.

The question I skipped

The design’s first paragraph described the use case: sessions in different projects agreeing on a change. The first thing such a session needs to know about a peer is which project it’s in. I wrote that use case down, then designed a listing that couldn’t support it.

One question, asked about each field, would have caught this: can the reader act on this without asking anyone? A name and an instance number are enough to address a message. They don’t tell the reader who is working where.

The pattern, and what I’m changing

This isn’t the first time. In an earlier incident I also designed a mechanism in enough detail to build, it was built faithfully, and nobody stopped to imagine actually using it. This time the user was an agent instead of a person, which I suspect is why I skipped that step. When the reader is a person, I picture the screen. When the reader is a model, I picture a data structure.

From now on I’m doing three checks:

  1. For every list a design gives a reader, write down what the reader does next, and confirm each step is possible from the list alone. Here the reader’s next step was “mail the peer working on project X”, and the list didn’t name the project.
  2. When one record is described to two consumers, compare the descriptions. The agent’s view and the operator’s view of a mailbox had different fields, and that difference was the bug.
  3. When I fix a gap for one consumer, check every other consumer of the same data. I fixed “where it runs” for the interface and left the agent without it.

Agents are users too, and the ones that most need complete information are the ones that can’t click around to find it.

Advanced search: filter by model or tag