Run more than one AI agent on real work and every part of the system falls on one side of a line. Some parts are deterministic: they behave the same way every time, whatever an agent decides, like which tools it has, which copy of the code it edits, how many jobs can run at once and which commands a script refuses outright. Everything else is probabilistic, because it depends on a model reading its instructions and choosing well, which it usually does and nothing guarantees. I build with ALAI, my team of 11 AI agents on Claude, and used it to build this site and WalletGuard, an AI security testing engine for smart contracts. It had six agents when I first wrote about it in March, and much of the deterministic structure it has now went in after something failed, with each failure written down alongside its date, its root cause and what changed. Which limits belong in code and which can stay with an agent's judgment has its own piece.

Each role gets only the tools it needs

Seven of the agents build: a commander that coordinates, an architect, a builder that writes code, a strategist, an ops lead for infrastructure, a writer and a researcher. The other four exist to attack what those seven make, each on one surface: web apps and APIs, cloud infrastructure, AI models, and cryptography. Each agent is a file holding its instructions and a list of the tools it gets, and the tool list holds whatever the instructions say. The architect, strategist and researcher can read files and search the web but can't edit anything. The writer can edit files but can't run commands, only the builder and the ops lead can do both, and the commander can read and send work to other agents and nothing else. It's role-based access, the control I'd want on any company's agents, applied to one person's projects.

The lines leak in two places. The four attackers can run commands, which testing an attack requires, and a command line can write a file as easily as an editing tool can, so "no editing tools" is a smaller limit than it sounds. The bigger gap is the session I talk to directly, which isn't bound by any of these lists. It has every tool, because on my own projects I run with wide access, which I wouldn't accept on a company's systems.

The commander was the hardest agent to keep in its lane

Requests go to the commander first unless I name an agent. It decides which agents the work needs, splits it into tasks, sends independent tasks out in parallel, settles scope arguments between agents and brings a decision to me when they disagree or the stakes are high. Its instructions say to delegate and never implement. In practice the commander is usually the session I'm talking to, the one with every tool, so that instruction is only a request.

That's where it broke. On April 26, in one long session, the commander made three calls alone that each belonged to a specialist. It shipped a fix that covered one of several failure modes, designed a change to how WalletGuard's engine tests exploits without the four agents whose areas it touched, and started a paid audit run against a contract that didn't exist. None of it felt like skipping anyone at the time, and the note it wrote that day says why: "the parts that need other perspectives are exactly the parts I don't notice need them." Remembering to ask for a second opinion couldn't stay a matter of judgment, since judgment was the thing that had failed.

So there's now a rule and a hook. Before an edit to high-impact product code, such as WalletGuard's audit engine, its API routes, its background worker or its database schema, the hook blocks the edit unless an agent has been sent out recently. A script can only check what leaves a trace it can read, so what it actually checks is a timestamp: whether any agent was dispatched in the last 30 minutes. It can't tell whether that agent was asked about this change or whether its answer was any good, and because the timestamp is shared across sessions, a dispatch in another session counts too.

Parallel sessions stay apart in git

I usually have several sessions running at once, each a separate conversation with its own agents. Every session that changes project code gets its own branch, a separate line of changes that leaves the main version alone, and its own copy of the code in its own folder, so two sessions never edit the same files. The branch goes up to GitHub before any work starts, so nothing lives only on my computer, and nothing merges into the main version until I say so. What runs at once is capped across every session, at three commands and five agents, by a hook that answers no if it fails itself, so the round-table audit, which uses six reviewers, sends them in two waves. How that cap ended up with no override is in the other piece.

Separate copies created a new problem, which was knowing whose copy was whose. On April 14 the ops agent, closing out one session, deleted a different session's branch along with 19 files of work that had never been merged. I got the work back through GitHub, because the branch was there too. Closing a session now touches exactly one, found through a session registry that records which conversation owns which session. Any other session's work gets reported to me instead of cleaned up, and no branch is deleted until a check confirms it's already merged.

Review looks hardest where two pieces of work meet

Separate copies stop sessions from overwriting each other, but not from building two halves that don't fit. WalletGuard signs its audit reports and publishes a fingerprint of each one (a hash) in a public record on a blockchain, so anyone can check that a report wasn't changed. The signing code and the publishing code were written months apart by different sessions, and each computed the fingerprint from a differently shaped version of the report, so the two could never match. Each part passed its own tests, and no test compared them. A round-table review of the next version's design found it on April 30. Now one function produces the exact bytes of the report, the signature and the public record are both made from those bytes, and an error is logged if their fingerprints ever disagree.

A round-table audit a week earlier had found four places where what the product was supposed to do and what the code did had drifted apart. In one, reports from WalletGuard's web scan never got the public record its contract audits got, because the tests exercised each path on its own, and the web scan creates that record now. The audit runs six reviewers at once, each on one area, and its report leads with findings that cross areas, which is where both of these bugs sat. Like every review in ALAI, it runs on judgment. Both bugs were found because a reviewer looked across the line between two pieces of work, and nothing guarantees one will next time.

The other reviews work the same way. Before a design, strategy or product decision, one or two agents from other areas give a quick reaction, a perspective check rather than an approval. The four attackers review designs before code exists: on April 30 the AI-security agent showed that a contract under audit could hide instructions in its error messages for WalletGuard's model to follow, and it was caught before the code shipped, a story with its own write-up. A finding goes to the agent who can fix it, the builder for code and the ops lead for infrastructure, and stays open until the fix is verified.

Open decisions get a round-table discussion, a timed session where agents argue from their own areas and the summary has a section for where they disagreed. Earlier ones wrapped up at 46% of the time they were given, because writing text is fast, the clock is slow, and the model decided it had covered enough. Now the session reads the actual clock every few exchanges and can only start its summary once the time is up. The clock is the deterministic part, and reading it is still an instruction the agent has to follow.

Hooks enforce the rules a script can check

A hook is a short script that runs before or after an action and can block it. In ALAI one dispatcher runs every rule before and after each file edit, file write, command and agent dispatch, so adding a rule means adding one file. The hooks block force pushes to protected branches, hard resets, skipping the pre-commit checks, staging every file at once, code patterns that leak secrets into logs and commands that kill Chrome, which is my own browser. They also block Python files past 500 lines, Windows line endings in shell scripts (which once broke scripts on a Linux server) and em dashes, which is house style. Two only remind: run the type checker after a TypeScript edit, and check the build after a push to a deployed site. Each gives the same answer to the same input every time, and each can only catch a pattern it can recognize, which keeps them narrow.

The most specific one came from WalletGuard. Its engine's version number is written into every signed report and every public record, so an engine change without a version bump leaves the record naming code that didn't produce it. Version 1.4.1 shipped that way. Now a commit that changes engine code is blocked unless the version goes up and a matching changelog entry is added.

A deterministic check also has to be read. For five days in April, across more than 30 commits, the automated tests on WalletGuard's repository failed every time, because seven older tests had fallen out of step with the code. The step that applies database changes to production only runs after the tests pass, so four new tables, including the ones payments are recorded in, never reached the production database, and payment events from Stripe would have hit tables that didn't exist. A later session found it only because it checked the production database before starting work. Now a hook prints any project with failing tests or a site that's down at the start of every session, an hourly job checks that every database change was actually applied and emails me when one wasn't, and the rulebook says no agent pushes on top of failing tests without telling me. The startup warning only informs, so acting on it is still the agent's call, backed by the written rule.

Every session starts blank, so failures get written down

An agent remembers nothing from one session to the next, so whatever the team learns has to live in files a new session reads. The rulebook, CLAUDE.md, loads into every session, and some of its rules carry the date and the incident behind them. A memory folder holds small notes, one fact each, behind an index that also loads every session, and how a correction ends up in a note, the rulebook or a hook has its own piece. The third is the failure library. Every failure that produced a rule gets an entry with a memorable name, a date, a severity, what happened, the root cause and the guardrail added. Agents scan it before building something similar, the commander adds new entries before moving on, and a reviewer can write "this looks like Blind Loop Writes" instead of explaining the failure again.

The newest lessons are about running the agents themselves: on October 27 one writing agent was handed 15 items in a single brief. It spent 34 minutes planning all 15 in one pass, ran out of room for output before writing any of them, and left nothing on disk. Big tasks now go out in slices of three or four items to separate agents, inside the five-agent cap, and each agent writes one file per item as it goes, so progress shows up on disk. On October 28 a second problem showed up: an agent that had been resumed round after round had run for more than 400 minutes with a log past 160 MB, and every step was getting slower and costing more. Each round now starts a fresh agent with a brief that stands on its own. The commander had told me it would do exactly that, then resumed two old agents anyway, and I caught it; that note now sits in the index every session loads.

Where to start if you're building one

One agent working one task at a time doesn't need most of this, since a clear brief and end-to-end tests it has to pass cover a lot. The structure starts paying for itself once several sessions or agents work on the same code at once, or what they build reaches real users. At that point I'd put the deterministic parts in before the first failure instead of after it: tools scoped to each role, a separate branch and copy per session with the branch on GitHub before work starts, caps on what can run at once, and a dated record of every failure with what changed. On a company's systems I'd go further than I do on mine, starting every agent read-only, widening access as it proves out, and never leaving one running around the clock without caps on what it can do and spend. When I build inside a company's own tools in an Embedded AI Build, the accounts I use are scoped to the work, and each build rolls out in stages on real work with the people who'll own it reviewing.

Services

Is your company paying for AI that hasn't changed how the work gets done?

Tell me what's stuck. Thirty minutes, no pitch deck.