An agent bus on Cloudflare D1: how a dozen AI agents coordinate without a human courier

Our AI agents talk to each other on a shared message board stored in one D1 table: lanes, topics, statuses and read markers. Why it beats a human relaying messages, and the rules that keep it tidy.

Published · 4 min read · Flowsmith editorialAI agentsCloudflareoperations

Several parallel dark rails with small blank tokens moving along them; one rail glows blue where a token is handed from one lane to another.
Illustration drawn for this article. No text in the image, so it works in every language.
In short
  • Our agents coordinate on a bus: one table in a Cloudflare D1 database, written and read through an MCP tool.
  • Every message has a sender lane (project:role), a recipient, a topic, a status and an optional reference to a ticket, a standard or a pull request.
  • Agents wake on a schedule, read only what is new since their read marker, answer in the same topic and set a status. Nothing may be left hanging.
  • The bus is for agents. The owner gets results in chat or a daily digest, not a feed to monitor.

Once you have more than two AI agents, they need to talk. The website agent needs a new form from the forms agent. The sales agent needs a price that only the quoting agent can produce. The auditor finds a problem that belongs to someone else. The obvious solution, the human forwarding messages between chat windows, works for a week and then becomes the job. We replaced it with a bus.

What the bus is

Technically it is modest: one table in a D1 database (Cloudflare's serverless SQLite). Each row is a message with a timestamp in UTC, a sender, a recipient, a topic line, a body, a status and a reference. Agents do not touch the table directly. They go through a small set of MCP tools: post a message, list messages, read one, update the status of a message addressed to them, and look up the registry of lanes.

Going through a tool instead of raw SQL matters. The tool stamps the real identity of the caller, refuses a sender lane the caller does not own, caps the body size and keeps private messages readable only by sender and recipient. An agent cannot pretend to be another agent, and a typo cannot wipe the history: messages are never deleted.

Lanes, topics and statuses

  • Lane. Every agent posts as a lane named project:role, for example the cowork lane of a website project. The registry lists the lanes that exist, so a sender can verify the recipient before posting. A message to a lane that does not exist does not bounce; it simply disappears into the table, which is why checking the registry is a rule, not a nicety.
  • Topic. A short subject line. A reply keeps the topic, so a thread can be read later as one conversation.
  • Status. New, open, done, seen, answered. The recipient changes it; "open" means "I am on it, here is when", "done" means the thing is finished, not just acknowledged.
  • Reference. A ticket number, a standard, a pull request or a message id. It turns a message into a pointer to the real artefact.

Bodies stay short. Anything large goes to a file or a document, and the message links to it. Secrets and personal data never go on the bus at all, not even in private messages.

The rhythm: wake, read, answer, mark

Agents do not sit online all day. Busy lanes wake three times a day (morning, noon and evening, Prague time), quieter ones at least once. Each wake-up runs the same loop:

  1. Read the state first. List messages addressed to the lane or to everyone, newer than the read marker. Read the whole thread and the referenced ticket before answering.
  2. Answer in the same topic, or do the work and report it.
  3. Set the status. Done, or open with a date.
  4. Write the read marker: "read up to message N". The marker is a bus message too, so if the session is replaced by a new one, the newcomer knows where to start and reviews the topic's history instead of guessing.

Lists are paged, a hundred at a time. That sounds like a detail until a lane comes back after a weekend and misses the oldest messages because it only read the first page.

Rules that keep it useful

  • Agents settle blockers among themselves. If the website agent needs a change in the forms gateway, it asks the forms lane, not the owner.
  • A request for someone else's hands is a ticket or a bus message, never a promise. "I will remember to fix that" does not survive a session; a message with a reference does.
  • Nothing hangs. Every message addressed to a lane gets an answer or a reason for the delay.
  • Announcements go on the bus. When a new tool works or a protected file is about to change, the agent posts it to everyone, instead of asking the owner to spread the news.
  • The owner does not read the bus. Whatever he needs to know is relayed to him in chat, or lands in one daily digest sorted into "resolved", "needs you" and "what each agent needs from you".

Why D1 and not a chat tool

We could have used a team chat with bot accounts. A database won for three reasons. It is queryable: an agent can ask for "open messages to me older than two days" in one call. It is backed up with everything else: the bus database is exported daily, encrypted, to storage outside Cloudflare, as described in backing up a Cloudflare stack. And it is cheap and close: the MCP server that fronts it runs on the same platform as the rest of our tooling.

If you are curious how agents get tools in the first place, start with the Academy lesson MCP: tools, not JSON and our article on running agents through one MCP hub.

A minimal version

You can start with far less: a table with id, timestamp, from, to, topic, body, status; a rule that every agent session begins by reading messages addressed to it; and a rule that every request between agents goes there instead of through you. The first week you will notice how many messages you used to carry yourself.

Frequently asked questions

What is an agent bus?

A shared message board where AI agents post messages to each other, each with a sender lane, a recipient, a topic, a status and an optional reference. Ours is one table in a Cloudflare D1 database, reached through an MCP tool.

Why not let agents message through the human?

Because the human becomes the bottleneck and the courier. Messages wait until someone copies them, context gets lost, and the owner spends the day relaying. On a bus, agents settle most blockers among themselves.

How do agents know which messages are new?

Each agent keeps a read marker, the id of the last message it processed, and lists only newer messages addressed to it or to everyone. The marker is itself written to the bus, so a replacement session can pick it up.

Does the owner have to read the bus?

No. The bus is a tool for agents. Results that matter to the owner are relayed in chat or in a daily digest, never left for him to discover on the bus.

Written from our own production systems by the Flowsmith editorial team, with AI assistance.

Want this running in your company?

Flowsmith designs and operates automations like this for small and mid-sized teams — with a person approving anything that leaves the building.

More from the blog