Executive Summary
- One prompt does not scale: Workly Mail started as a single mega-prompt. It hit a quality ceiling fast. The fix was decomposition, not a bigger model.
- The swarm is a team, not a chatbot: An orchestrator plus seven specialist agents — triage, retrieval, drafting, scheduling, compliance, summarization, and a critic — each with a narrow contract.
- Coordination is the hard part: Message passing, shared state, and explicit hand-off contracts mattered more than any individual agent’s prompt.
- Reliability is engineered, not prompted: Bounded loops, a critic gate, idempotent tool calls, and per-agent timeouts turned a flaky demo into a system we could put in front of customers.
Every team that ships a serious AI product reaches the same wall. You start with one prompt that does everything: read the email, understand intent, pull context, draft a reply, check the calendar, stay on-brand, and never leak anything sensitive. It demos beautifully. Then real traffic arrives and the cracks show — the model forgets step three, contradicts step five, and confidently schedules a meeting on a day that does not exist.
Workly Mail — our AI email operations product — lived through exactly that arc. This is the teardown: how we moved from a single overloaded prompt to a coordinated swarm of specialist agents, what the architecture actually looks like, and the failure modes we had to engineer around to make it production-grade. If you are a CTO or staff engineer evaluating whether multi-agent is hype or substance, this is the honest version. The architectural shift is real, but so is the engineering tax.
Why a Single Prompt Hit a Ceiling
The first version of Workly Mail was one function call. A long system prompt — roughly 1,800 tokens of instructions — wrapped the incoming email, the user’s recent thread history, and a pile of rules. It worked for the happy path and fell apart everywhere else.
The problem was not the model’s raw capability. It was cognitive load distribution. When you ask a single inference pass to simultaneously classify intent, retrieve facts, reason about scheduling, apply compliance rules, and produce polished prose, you are forcing one attention budget to cover five unrelated tasks. Quality degrades on all of them, and the failures are correlated: a bad intent read poisons the draft, which trips the compliance rule, which the model then papers over.
Three symptoms told us we had outgrown the monolith:
- Instruction decay: rules near the top of the prompt were honored; rules near the bottom were quietly dropped under load.
- No observability: when an output was wrong, we could not tell which sub-task failed. The whole thing was one opaque pass.
- Untestable units: we could not unit-test "scheduling logic" in isolation because it did not exist as a unit. Everything was entangled.
The instinct many teams have here is to reach for a bigger or newer model. We tried that. It moved the ceiling up by maybe ten percent and tripled our cost per email. The real answer was architectural: stop asking one agent to be everything, and build a team.
The reframe that unlocked it: Stop thinking of the LLM as a brain you prompt. Start thinking of it as a workforce you organize. A monolith prompt is a single employee doing seven jobs badly. A swarm is seven specialists with one manager — and a manager’s job is coordination, not doing the work.
The Anatomy of the Swarm
Workly Mail’s production architecture is an orchestrator-worker topology. One coordinating agent owns the workflow and never touches the actual content tasks. Below it sit seven specialist agents, each with a narrow, well-documented contract. This is the same pattern that underpins most credible production multi-agent systems today, and it is the one we recommend in nearly every AI agent development engagement.
The Orchestrator
The orchestrator is deliberately "dumb" about content and smart about flow. It does not draft emails. It decides which agent runs next, what context that agent receives, and when the workflow is done. Its system prompt is short — under 600 tokens — and its job is routing, sequencing, and enforcing the stop conditions. Keeping it lean is intentional: a coordinator that also reasons about content reintroduces exactly the entanglement we were trying to escape.
The Seven Specialists
- Triage Agent: classifies the incoming email — intent, urgency, required actions. It outputs a structured label set, nothing prose. Everything downstream keys off this.
- Retrieval Agent: pulls relevant context from the user’s mailbox, CRM, and knowledge base. This is a retrieval-augmented generation layer with citation tracking, so every fact the system uses is traceable to a source.
- Drafting Agent: writes the actual reply, given the triage labels and retrieved context. It is the only agent allowed to produce customer-facing prose.
- Scheduling Agent: handles anything calendar-related, calling deterministic tools rather than reasoning about dates in natural language (the single biggest source of early hallucinations).
- Compliance Agent: checks the draft against data-handling rules, brand constraints, and forbidden actions. It can veto, not rewrite.
- Summarization Agent: compresses long threads into a working context so downstream agents are not drowning in history.
- Critic Agent: the quality gate. It scores the draft against the original intent and either approves it or sends it back with specific, actionable feedback.
The discipline that makes this work is the narrow contract. Each agent has one job, a typed input, and a typed output. The Triage Agent cannot draft. The Drafting Agent cannot approve its own work. This separation is what gives us observability: when something goes wrong, the trace tells us exactly which agent produced the bad output and what it received.
Coordination: The Part Nobody Warns You About
Here is the lesson that cost us the most time: the agents were never the hard part. The coordination between them was. Once you have specialists, you inherit every problem a distributed system has — state, ordering, partial failure, and the question of who owns the truth at any given moment.
Message Passing and Shared State
We rejected the naive design where each agent stuffs its full output into the next agent’s prompt. That just rebuilds the monolith one hop at a time, and the context window balloons with every step. Instead, agents communicate through a structured shared state object — a typed blackboard. Each agent reads the slices it needs and writes only its own slice. The orchestrator owns the schema.
# The shared state passed between agents — typed, not free text
state = {
"triage": { "intent": "reschedule_meeting", "urgency": "high" },
"retrieved": [ "thread:8842", "crm:contact:114" ],
"draft": None, # filled by Drafting Agent
"compliance": None, # PASS / VETO + reason
"critic_score": None # 0.0 - 1.0, gates the loop
}
This typed blackboard is unglamorous and it is the single most important design decision in the whole system. It keeps context windows small, makes every hand-off auditable, and means we can replay any workflow deterministically from its state log.
Hand-off Contracts
Every transition between agents is governed by an explicit contract: what must be present in the state before this agent runs, and what it guarantees to add. If the Drafting Agent runs before retrieval has populated context, that is a contract violation the orchestrator catches — not a subtle quality regression we discover in production three weeks later. Treating hand-offs as contracts, the way you would an API boundary, is what separates a multi-agent system from a pile of chained prompts.
Engineering for Reliability
A multi-agent system has more moving parts than a monolith, which means more ways to fail. Reliability here is not something you prompt your way into. It is engineered with the same boring rigor you would apply to any distributed system. Four mechanisms did most of the work.
Bounded Loops
The Critic Agent can send a draft back to the Drafting Agent for revision. Left unbounded, two agents will happily ping-pong forever, burning tokens and latency. Every loop in Workly Mail has a hard ceiling — typically two revisions. If the critic is still unhappy after the cap, the workflow escalates to a human rather than spinning. A swarm without loop bounds is a runaway cost incident waiting to happen.
The Critic Gate
Self-critique is the highest-leverage pattern we deploy. A dedicated agent whose only job is to evaluate another agent’s output catches a remarkable share of errors before they reach a user, precisely because it is not invested in the draft it is reviewing. The research on this is now substantial; the Reflexion line of work formalized what we see empirically — separating generation from evaluation measurably improves reliability.
Idempotent Tool Calls
Agents take real actions: sending mail, booking calendar slots, updating CRM records. In a system with retries and bounded loops, the same action can be attempted more than once. Every side-effecting tool is therefore idempotent — guarded by an idempotency key — so a retry never double-books a meeting or sends a reply twice. This is standard practice in payments engineering; it is just as essential the moment an LLM is allowed to touch the outside world.
Per-Agent Timeouts and Fallbacks
Each agent runs under its own timeout and has a defined fallback. If the Retrieval Agent stalls, the orchestrator proceeds with reduced context and flags the draft as lower-confidence rather than hanging the entire workflow. Graceful degradation beats a frozen swarm every time.
The mental model that kept us honest: Treat your agents like microservices, not like a conversation. Conversations are forgiving and vague. Microservices have contracts, timeouts, retries, idempotency, and observability. The teams that ship reliable agents are the ones who bring distributed-systems discipline to a problem that looks like prompt engineering.
What It Cost — and What We’d Do Again
Multi-agent architecture is not free. Being specific about the trade-offs is the only honest way to write this up.
- Latency went up. Seven agents and an orchestrator mean multiple sequential inference passes. We claw most of it back by running independent agents in parallel (triage and retrieval overlap) and by using small, fast models for the narrow tasks — the orchestrator and triage do not need a frontier model.
- Token spend shifted. More calls, but each call is short and focused, so total cost rose less than you would expect — roughly 1.3x the monolith, for a quality jump that made the product viable. Routing simple tasks to cheaper models is the main lever; see our breakdown of what a production agent actually costs.
- Operational complexity is real. You now run a distributed system. You need tracing, per-agent metrics, and replayable state logs. Budget for that platform work from day one — it is not optional polish.
The payoff justified all of it. Output quality on our internal eval set rose substantially, and — more importantly — failures became diagnosable. When something breaks now, the trace points at one agent with one bad input. We fix that agent in isolation, re-run its unit evals, and ship. That feedback loop, not any single clever prompt, is what made Workly Mail a product instead of a demo.
A word of caution to balance the enthusiasm: multi-agent is the wrong tool for plenty of problems. If your task genuinely fits in one focused prompt, a swarm adds cost and latency for nothing. We wrote separately about exactly when not to use a multi-agent system, and that caveat is load-bearing. The architecture earns its keep when the task is genuinely multi-stage, the stages are heterogeneous, and reliability matters more than raw speed.
Observability: How We Actually Debug a Swarm
When the monolith failed, debugging meant staring at one input, one output, and a shrug. With seven agents and an orchestrator, you would assume debugging gets seven times harder. In practice it got dramatically easier — but only because we invested in observability before we needed it. This is the part teams underestimate, so it is worth being concrete about what we built.
The Trace Is the Source of Truth
Every workflow emits a structured trace: the initial input, each agent invocation with its exact input slice and output slice, every tool call with arguments and results, and the final state. Because agents communicate through the typed blackboard rather than free-text prompts, the trace is genuinely readable — you can follow the reasoning from triage to delivery without reverse-engineering a 6,000-token prompt. When a customer reports a bad reply, we pull the trace by request ID and the failing agent is usually obvious within seconds. We are no longer debugging "the AI." We are debugging a specific function that received a specific input and produced a specific wrong output.
Per-Agent Evals, Not End-to-End Vibes
The decomposition pays off most in testing. Each agent has its own eval set — fixed inputs with known-good outputs — that we run on every change. The Triage Agent is evaluated as a classifier, with precision and recall on intent labels. The Scheduling Agent is evaluated against a deterministic oracle, because dates either resolve correctly or they do not. The Critic Agent is evaluated against a labeled set of good and bad drafts to measure how often it catches real problems versus how often it nitpicks acceptable work. This is impossible with a monolith, where the only test you can write is an end-to-end "does the whole thing feel right," which is slow to run and tells you nothing about why a regression happened.
We gate deploys on these per-agent evals. A change to the Drafting Agent’s prompt that improves tone but drops the critic pass rate gets caught before it ships, not after a customer notices. That guardrail is only possible because the agents are isolated units with their own contracts and their own tests.
Cost and Latency as First-Class Metrics
We instrument token spend and latency per agent, per workflow. This surfaced non-obvious wins. The Summarization Agent, it turned out, was our most expensive component because it processed long threads on every run — so we cached summaries keyed on thread state and cut its cost by more than half with no quality loss. You cannot make optimizations like that when the whole system is one inference call; you have no idea which part of the prompt is costing you. Granular metrics turn cost control from guesswork into engineering. For teams wiring agents into existing tools and data, this instrumentation work is a core part of any serious AI integration effort, not an afterthought.
A Blueprint You Can Apply
If you are about to build your own swarm, the sequence that worked for us was deliberate and worth copying. Start by decomposing the task into the smallest set of distinct cognitive jobs — resist the urge to over-split, because every agent is coordination overhead. Give each one a typed input and output before you write a single prompt; the contract is the design. Build the orchestrator as a pure router that owns the shared state schema and never produces content. Add a critic gate early, because evaluation-as-a-separate-step is where most of your reliability will come from. Then wrap the whole thing in the boring distributed-systems machinery — timeouts, bounded loops, idempotent tools, and tracing — that turns a fragile prototype into something you can put a customer’s name on. Frameworks like LangGraph formalize a lot of this state-and-edges thinking, but the discipline matters more than the framework.
This pattern generalizes well beyond email. We have applied the same orchestrator-worker topology to customer support triage, contract review, and internal RevOps automation. The domain changes; the architecture and the engineering rigor do not. That portability is the strongest argument that multi-agent design is a durable pattern rather than a passing trend, and it is why it sits at the center of how we approach AI-powered application development at Ayraxs.
Conclusion
The shift from one prompt to a coordinated swarm is not about chasing a buzzword. It is about distributing cognitive load, regaining observability, and making AI systems testable and reliable enough to trust in production. The agents are the easy part. The orchestration, the contracts, and the engineering discipline are where the real work lives — and where the real advantage is.
Thinking about whether a multi-agent architecture is right for your product? Book a multi-agent architecture review with Ayraxs. We will tell you honestly whether you need a swarm or a single sharp prompt — and how to build whichever one wins.
