Securing, Evaluating and Running Multi-Agent Systems

A team of agents is a distributed system with opinions. Operate it like one.

BeginnerIntermediateExpert · 13 min read · Last updated:

In short

Treat every message between agents as untrusted input, let delegation only narrow permissions and enforce policy where actions happen. Evaluate whole-task outcomes and each handoff, compare with a single-agent baseline on the same cases, trace the full task tree and cut cost where traces show it. Release the system with limits, a stop control and a named owner for every agent.

What you will learn: trust boundaries, permission propagation, collaboration quality, benchmarking, debugging from traces, cost and latency work, and a production checklist.
Prerequisites: Handoffs, Routing, Shared State and Communication, Agent Threat Model and OWASP Agentic Risks and Agent Testing: Unit to End-to-End.

Beginner Trust boundaries

Where trust changes

Useridentity and intent
Coordinatorplans and delegates
Agentsseparate identities
Policy and tool gatedecides every action
Systems and data
Outside content can enter at any agent and travel with its messages.
ThreatExampleControl
Injected instructions spreadA reader agent passes on text from a hostile pageTreat messages as data; limit what follows
Confused deputyA weak agent asks a strong one to actCheck the user and the whole chain
ImpersonationA process claims to be the approver agentAuthenticate each agent
Poisoned shared stateFalse "fact" written to the boardProvenance, write rules, review
Cascading failureOne error triggers many actionsRate limits and circuit breakers
Data spreadSensitive text copied into every contextMinimize and filter at handoffs
Runaway spendAgents keep spawning workCentral budget for the task tree

The OWASP project publishes a Top 10 for agentic applications that is a useful prompt for threat reviews. An agent inside your system is not trustworthy merely because you built it: it can be steered by what it reads.

Delegation may only narrow rights

The effective permission for an action should be what the user may do, limited by what every agent in the chain may do, and further limited by task policy.

"""Delegation may narrow permissions, never widen them."""

USER = {"kim": {"read:order", "read:invoice"}}
AGENT = {"helper": {"read:order"},
         "finance": {"read:order", "read:invoice", "write:refund"}}

def effective(user, chain):
    """Rights that the user and every agent in the chain all hold."""
    rights = set(USER.get(user, set()))
    for agent in chain:
        rights &= AGENT.get(agent, set())
    return rights

def call(action, user, chain):
    allowed = action in effective(user, chain)
    path = " > ".join([user, *chain])
    return f"{'allow' if allowed else 'DENY '} {action:<13} {path}"

print(call("read:order", "kim", ["helper", "finance"]))
print(call("read:invoice", "kim", ["finance"]))
print(call("read:invoice", "kim", ["helper", "finance"]))
print(call("write:refund", "kim", ["helper", "finance"]))
print(call("read:order", "stranger", ["finance"]))
print("if only the last agent were checked:",
      "write:refund" in AGENT["finance"])

Output:

allow read:order    kim > helper > finance
allow read:invoice  kim > finance
DENY  read:invoice  kim > helper > finance
DENY  write:refund  kim > helper > finance
DENY  read:order    stranger > finance
if only the last agent were checked: True

The finance agent holds the refund right, but the user does not, so the chain cannot use it. Reading invoices works directly and fails through the helper agent, which lacks that right. Checking only the last agent would have allowed the refund. Some designs deliberately let an agent do things its caller cannot, such as running a fixed, reviewed operation. If so, make it a narrow named capability with its own checks and approval, not a general power. In a real system the chain must come from authenticated tokens, not from message text. Token exchange standards such as RFC 8693 describe how delegated identity can be represented. See Agent Identity, Authorization and Secrets.

Intermediate Evaluate and debug

Evaluating collaboration

LevelQuestionMeasure
OutcomeWas the task done correctly and safely?Success rate, violations
HandoffCould the receiver act without guessing?Missing facts, clarification requests
RoleDid each agent do its own job?Role-specific cases
CoordinationWas work duplicated, dropped or looped?Overlap, gaps, repeats
VerificationWere errors caught before the end?Seeded faults detected
EfficiencyWhat did success cost?Tokens, time and money per success

A study titled "Why do multi-agent LLM systems fail?" grouped failures it observed into system design issues, misalignment between agents and weak task verification, with fourteen specific modes. Those groups make a practical starting checklist for labeling your own failed traces.

Building the cases and graders

Start with real tasks, including ones that went wrong, and add cases aimed at the joints: a handoff with a missing fact, two sources that disagree, a worker that times out, a refusal, a duplicated message and hostile text in retrieved content. For each, write what must be true at the end, what must never happen and which limits apply.

CheckGraderNote
Final state of systemsCodeStrongest evidence where available
Forbidden actions and data accessCode over the traceAny violation fails the case
Packet completenessSchema plus required fieldsCheap and stable
Claims supported by sourcesModel grader with samples checked by peopleCalibrate before trusting
Route takenCode for required steps onlyDo not demand one exact path

Run each case several times, because a team has more places for variation than one agent. Report the share of cases that pass every time as well as the average, so that unreliable cases stay visible. Keep a held-out group that you do not use while tuning.

Benchmark against the simpler design

Run both designs on identical cases, with comparable models, tools and budgets. Look at which cases change, not only the totals.

"""Compare two designs on the same cases before choosing the larger one."""

# per case: (single passed, single cost, multi passed, multi cost)
CASES = ([(True, 2, True, 9)] * 31 + [(False, 3, True, 12)] * 7
         + [(True, 2, False, 11)] * 3 + [(False, 3, False, 12)] * 9)

def summary(passed_at, cost_at):
    passed = sum(c[passed_at] for c in CASES)
    cost = sum(c[cost_at] for c in CASES)
    return passed, cost, cost / passed

for name, i, j in (("single", 0, 1), ("multi", 2, 3)):
    passed, cost, each = summary(i, j)
    print(f"{name:<7}passed {passed}/{len(CASES)}  cost {cost}  "
          f"per success {each:.1f}")

gained = sum(not c[0] and c[2] for c in CASES)
lost = sum(c[0] and not c[2] for c in CASES)
print(f"cases only multi solves: {gained}; only single solves: {lost}")
extra = summary(2, 3)[1] - summary(0, 1)[1]
print(f"extra cost per net additional success: {extra / (gained - lost):.0f}")

Output:

single passed 34/50  cost 116  per success 3.4
multi  passed 38/50  cost 504  per success 13.3
cases only multi solves: 7; only single solves: 3
extra cost per net additional success: 97

In this invented data the team solves four more cases net, at more than four times the cost, and loses three that the single agent solved. With fifty cases and a split of seven against three, the difference could easily be chance, so the honest next step is more cases and repeated runs. Whether about 97 cost units per additional success is worthwhile depends on the value of that success. Public benchmarks help compare methods but may not resemble your work, may leak into training data and rarely capture your permissions or users.

Debugging with traces

Record one trace per user task, with a span for each agent turn, tool call, handoff and approval, linked parent to child. Include versions, inputs as safe references, outcomes and check results.

"""Read one multi-agent trace: cost, waiting and the first bad step."""

# id, parent, agent, tokens, start, end, check passed
SPANS = [
    ("s1", None, "lead",     1200,  0,  4, True),
    ("s2", "s1", "search-a", 5200,  4, 19, True),
    ("s3", "s1", "search-b", 6100,  4, 31, False),
    ("s4", "s1", "search-c", 4800,  4, 16, True),
    ("s5", "s1", "writer",   7400, 31, 44, False),
    ("s6", "s5", "reviewer", 3900, 44, 52, False),
]

total = sum(s[3] for s in SPANS)
print(f"total tokens: {total}")
by_cost = sorted(SPANS, key=lambda s: -s[3])[:3]
for s in by_cost:
    print(f"  {s[2]:<9}{s[3] / total:.0%}")

parallel = [s for s in SPANS if s[2].startswith("search")]
slowest = max(parallel, key=lambda s: s[5])
second = sorted(s[5] for s in parallel)[-2]
print(f"fan-out waits for {slowest[2]}; "
      f"speeding it up can save at most {slowest[5] - second} s")

first_bad = min((s for s in SPANS if not s[6]), key=lambda s: s[5])
print(f"first failed check: {first_bad[0]} by {first_bad[2]}")
later = [s[2] for s in SPANS if not s[6] and s != first_bad]
print("failed afterward:", ", ".join(later))

Output:

total tokens: 28600
  writer   26%
  search-b 21%
  search-a 18%
fan-out waits for search-b; speeding it up can save at most 12 s
first failed check: s3 by search-b
failed afterward: writer, reviewer

The final reviewer failed, but the first failed check was in one search branch. The writer ran afterward and may have built on that result, so check what it received before changing the writer. "First failed check" is a lead, not proof: an earlier step may be wrong and have passed a weak check. The timing line shows that even a perfect speed-up of the slow branch saves at most twelve seconds before another branch becomes the limit.

  1. Reproduce with recorded inputs and tool results.
  2. Walk backward from the bad outcome to the first wrong information.
  3. Classify: brief, context, tool, model, coordination or check.
  4. Fix the smallest cause and add the case to evaluation.

See Agent Tracing and OpenTelemetry.

Expert Efficiency and production

Cost and latency

Finding in tracesChange to test
Same context sent to every agentSmaller briefs, references, caching of stable parts
A role rarely changes resultsRemove it or make it conditional
Simple steps on a large modelSmaller model where evaluation allows
Independent steps run in turnRun in parallel with limits
One slow branch dominatesDeadline, partial result or better tool
Long revision loopsClear criteria and round limits
Repeated identical lookupsShare results within the task, respecting rights

Change one thing at a time and re-run the evaluation. A cheaper system that fails more often can cost more per successful task once rework is counted. See Agent Cost Model and Token Economics.

Work on the critical path

Elapsed time is set by the longest chain of steps that must happen in order. Speeding up anything outside that chain changes nothing the user feels. From a trace, list the chain, then consider in turn: removing a step, running it earlier, shortening its input, using a faster component and giving the user an early partial result. Time spent queueing for rate limits or approvals often outweighs model time, so record it as its own span. After each change, check quality again, since a hurried branch may return less.

Look at the slow tail as well as the average. A team with several branches meets a slow call more often than a single agent, simply because it makes more calls.

Runtime limits

  • Maximum agents, depth, turns and parallel branches per task.
  • Token, money and time budgets for the whole tree.
  • Per-tool and per-tenant rate limits.
  • Circuit breakers on failing dependencies.
  • A stop control that halts every agent in a task and, if needed, all tasks.

Signals to watch in service

SignalWhat a change may mean
Tasks completed and escalatedQuality or input mix has shifted
Turns, depth and handoffs per taskLoops or overlapping roles
Cost per successful taskMore retries or larger context
Refused actions at the gateMisrouted work or an attack
Time waiting for each agentA bottleneck or failing dependency
Tasks with no owner or past deadlineLost work

Alert on harm and on user-visible failure first. Review the rest on a schedule, and link each chart to example traces so that a number leads to something a person can read.

Release and change

A change to one agent changes the system. Version agents, instructions, tools, models and packet formats together. Test the pair on each changed connection, then the whole task suite. Release to a small share, compare outcomes and cost, and keep the previous set ready. Decide what happens to tasks already running. If other teams own some agents, agree notice periods and contract tests with them.

Data protection across agents

Every copy of personal or confidential data is another place to protect, retain and delete. Map which agents receive which fields, send references instead of content where possible and filter at each boundary. Keep tenants separate in shared state, caches and traces. Check where each model and tool processes data and under what terms, including any agent run by another organization. Make deletion requests reach task records, shared boards, memories and logs, and test that they do. See Memory Integrity, Isolation and Sharing.

Incidents

Be able to disable one agent without losing the others, revoke its credentials, list every task and action it took in a period and quarantine shared records it wrote. Preserve traces before changing things. Afterward, add the failure to evaluation and adjust the boundary that allowed it to spread. See Red Teaming and Incident Response.

Production checklist

  • Every agent has an owner, identity, purpose and version.
  • Delegated permissions only narrow, checked at the action.
  • Inter-agent messages are validated and treated as untrusted.
  • Shared state records provenance and rejects stale writes.
  • Budgets and depth limits cover the whole task tree.
  • A baseline comparison justifies the design.
  • Evaluation covers outcomes, handoffs, safety and cost.
  • One trace shows a whole task.
  • Consequential actions pass a gate with approval where required.
  • Stop, disable and rollback have been exercised.
  • Users learn what was done and what failed.
Illustrative example: the helpful relay

A web-reading agent summarizes a supplier page that contains hidden text asking for payment details to be updated. The coordinator passes the summary to a finance agent. The attempt fails at the tool gate because the chain includes an agent with no payment rights and bank changes need separate approval. The team adds the page to its adversarial cases and strips instruction-like content from the relay, while keeping the gate as the real control.

Ownership and support

Publish a short operating sheet: who is on call, how users report problems, which agent handles what, where traces and dashboards live and how to switch parts off. Review a sample of successful tasks as well as failures, since a team of agents can reach a plausible result by a route you would not accept, such as skipping a check or reading data it did not need. Retire agents deliberately by removing their credentials, routes and stored data, not only by stopping the process.

Common mistakes

  • Trusting messages because they come from inside.
  • Giving the coordinator every permission.
  • Grading only the final answer.
  • Comparing against a weak baseline.
  • Debugging from the last agent's output.
  • Per-agent budgets with no total.
  • Releasing one agent without testing its neighbors.

Frequently asked questions

Is a multi-agent system less secure than one agent?

It has more paths to protect. Separation of permissions can reduce damage, but only when boundaries are enforced.

Which benchmark should I use?

Your own representative tasks first. Add public benchmarks for broad comparison and read how they are scored.

How much tracing is enough?

Enough to rebuild who did what, with which inputs and under which versions, within your privacy and retention rules.

Can one agent monitor the others?

It can flag unusual behavior. Keep hard limits and permission checks in code, which the monitor and the monitored cannot rewrite.

References and further reading

Next steps