It was a Thursday evening, and my agents were busy. The PM was pushing a night of merges, DevOps was releasing, the developer agent was building new Settings pages. Then everything went quiet.
The dashboard wouldn't load. Messages to the agents timed out. Telegram stopped answering. Not one agent, all seventeen of them, at the same moment.
Nothing had crashed. The process was running. The machine was on. The network was fine. And still, nobody could get a word in.
This is the story of what happened, and why it matters for anyone running a team of agents. It's the second piece in my Harmonious Agents series.
What was going on
I asked Claude to find out why, and it went looking on the machine itself.
The AgentX daemon (the one program every agent talks through) was alive but not answering. Its waiting room for new connections was completely full, so every new request was turned away after a few seconds. That's why everything timed out at once: the dashboard, the phone app, the agents' own messages, the Telegram bots.
A snapshot of what the daemon was doing showed the same thing every time: its main thread was stuck inside a database read. Not crashed, not looping. Just reading, slowly.
Two things made that read slow. The database had grown large over three months of agent activity, mostly step-by-step records of every run. And the machine was short on memory, so parts of that database had to be fetched back from disk while the read waited.
The read itself came from a small background job: a monitor that checks every few seconds for finished runs it hasn't reviewed yet. Every time it ran, it went through every run since the day it was installed, months of them, most already reviewed. On a quiet day that cost about a second. That evening it cost far more.
Why one slow read stops everyone
AgentX runs on Node.js, and Node does one thing at a time on its main thread. Usually that's fine, because most work is waiting on the network, and waiting doesn't block anyone.
But the database library we use reads synchronously: while a query runs, the main thread does nothing else. No new connections, no Telegram polling, no timers, no answers. For the length of that read, the whole daemon is frozen.
One slow query, run often enough, becomes a traffic jam. Requests pile up behind it, the waiting room fills, and from the outside it looks like the system is down. Seventeen agents, all perfectly healthy, all stuck behind one read none of them asked for.
That's the part that stayed with me. No agent did anything wrong. They were all waiting on a single shared thing, and when it stalled, so did everyone.
The fix
That night:
- Restart the daemon. It finished the work already in progress, then came back clean a few minutes later.
- Back up the database, then clear out old step-by-step records nobody needed anymore, in small batches so the agents kept working while it ran.
In the code:
- The monitor now remembers where it stopped. Instead of going through every run since it was installed, it keeps a bookmark and only looks at what's new. A read that took about a second every few seconds now covers a few minutes of runs.
- A watchdog now tells on the next slow read. If the main thread is blocked for two seconds or more, the daemon writes it in the log. The next time something like this happens, it won't be a mystery. It will have a timestamp.
The first fix removes this cause. The second one is for the causes I don't know about yet.
One voice failing shouldn't stop the song
In the first piece of this series I listed ten principles. Number eight says: when an agent or a machine fails, the work waits and resumes. It doesn't vanish.
That night broke it twice. A single shared part stalled, and everyone stopped with it. Then the restart that fixed it dropped every piece of work agents were handing to each other at that moment. They didn't wait to resume; they failed and had to be asked for again.
So we changed that too. Since this week, a handoff that is cut off by a restart is sent again once the daemon is back, and a handoff to an agent that has hit its usage limit is held until the limit resets, instead of failing. Over the past week, restarts and usage limits caused most of our failed handoffs. Next week I'll know if this fixed it, and I'll share the number either way.
The lesson for anyone running agents is simple. Your agents are only as independent as the things they share. Find the one part everyone waits on, and make sure it can't hold the whole team hostage, or at least that it tells you when it does.