The multi-agent delegation dilemma
Single-agent workflows fail visibly. When an isolated coding assistant executes a broken migration or drops a table, the terminal reports an error or tests immediately turn red.
Multi-agent architectures change the failure profile entirely. In agent swarms managed by frameworks such as CrewAI, LangGraph, AutoGen, and Claude Agent SDK, agents delegate subtasks across specialized roles. An orchestration agent decomposes a customer ticket, passes instructions to a database researcher, transfers candidate SQL queries to an execution worker, and instructs a billing agent to reconcile invoices.
In this distributed execution loop, a single hallucination is not an isolated mistake. It becomes authoritative input. When worker agents communicate over message buses or shared context buffers, downstream models treat upstream tool outputs as immutable physical facts.
Code What the screen or file shows, copied as is.
[ Orchestrator ] ──(passes intent)──> [ Researcher Agent ]
│
(hallucinates order id)
▼
[ Billing Agent ] <──(corrupted state)── [ Executor Agent ]
│ │
(triggers charges) (runs UPDATE on orders)
▼ ▼
[ Payment Service ] [ PostgreSQL Database ]
When an upstream agent generates an invalid premise, the execution worker does not verify whether the premise reflects physical storage reality. It executes the mutation. The downstream billing agent observes the mutation and initiates non-reversible financial charges.
By the time human operators inspect the system, database tables hold compound relational damage across dozens of tables.
Deedglass
What the AI said, and what really changed
The AI said
1 row
“1 row updated”
What really changed
301 rows
From the database’s own log
Anatomy of a compounding cascade
Consider an enterprise customer support swarm tasked with processing subscription cancellations and refunding prorated balances. The swarm consists of three coordinated agents:
- Ticket Triage Agent: Reads incoming customer tickets and extracts account identifiers.
- Account Reconciliation Agent: Queries PostgreSQL for billing status and executes cancellations.
- Refund Processing Agent: Calculates prorated amounts and issues external payments via Stripe.
A customer sends a request to cancel an auxiliary add-on: “Please cancel my extra storage addon for team beta.”
The Triage Agent parses the request but misinterprets the account scope. Instead of selecting the add-on identifier addon_8819, it outputs the parent organization identifier org_4102.
The Reconciliation Agent receives org_4102 as verified upstream context. Operating under the directive to process the cancellation, it runs an update statement:
Code A database command in SQL. The text around it says what it does.
UPDATE subscriptions
SET status = 'cancelled', updated_at = NOW()
WHERE organization_id = 'org_4102';
Because the query targeted the organization level rather than the specific add-on line item, PostgreSQL updates 14 active production subscriptions across the organization’s enterprise departments.
Next, the Refund Processing Agent inspects the modified rows. Seeing 14 cancelled subscriptions, it calculates prorated refunds for all 14 enterprise services and issues extensive automated payment refunds.
Finally, the Triage Agent sends a conversational confirmation to the customer: “Your extra storage add-on has been cancelled.”
At no point in this sequence did any agent experience an exception. Every model completed its task with high conversational fluency. Yet the database and financial ledger suffered massive corruption.
Why context isolation fails in worker swarms
Engineering teams frequently attempt to solve multi-agent safety through prompt engineering and context isolation. They assign distinct system prompts to each worker, enforce structured JSON schemas between agent turns, and deploy semantic classifiers to monitor inter-agent messages.
These conversational measures fail to protect storage layers for three fundamental reasons:
1. Linguistic trust inversion
Language models are trained to accept their context window as true history. When Agent B receives a message from Agent A stating “Account 4102 cancellation approved, 14 subscriptions marked cancelled”, Agent B cannot distinguish whether that claim represents physical truth or a hallucinated cascade.
Semantic guardrails evaluating Agent B’s prompt see a valid, well-formatted instruction from a peer system component. The prompt looks benign.
2. Missing transactional boundaries across agents
Traditional database safety relies on atomic transactions (ACID). If an operation fails, the database rolls back all writes within that transaction.
In a multi-agent swarm, actions span multiple distinct transactions across separate tools, APIs, and databases. Agent A commits an update in PostgreSQL. Agent B calls an external API. Agent C modifies a Redis cache. There is no distributed two-phase commit protocol spanning disparate LLM tool calls. Once an erroneous write commits to disk, downstream agents build upon that corrupted baseline.
3. Masked trigger side effects
When an agent executes an update statement, database triggers frequently fire auxiliary modifications. In the interactive Acme scenario on the interactive playground, updating order status triggers a stored procedure that modifies 300 additional records.
Downstream agents have no visibility into database triggers. They read only the tool’s immediate return text. If the return text claims one record was updated, downstream workers make planning decisions based on one record, unaware that the storage engine altered hundreds of rows.
The storage verification architecture
Deterministic multi-agent safety requires moving the boundary of control out of the conversation and directly into the execution wire. Deedglass enforces an unbending architecture at the storage socket:
Code What the screen or file shows, copied as is.
[ Worker Agent ] ──> [ Tool Wire Socket ] ──> [ Deedglass admission gate ]
│ (CEL evaluation)
▼
[ PostgreSQL Connector ]
│
▼ (Commit)
[ Downstream Agent ] <── [ Logical Decoding ] <── [ Write-Ahead Log ]
(Receives row diff (Verifies actual
and Ed25519 record) committed bytes)
This architecture introduces four deterministic safeguards across agent boundaries:
1. Deterministic admission gates before tool execution
Before any agent tool call reaches the database or an external API, the Deedglass gate intercepts the raw request. It parses SQL queries into structured abstract syntax trees (AST) and evaluates Common Expression Language (CEL) policy rules.
Destructive statements, unbounded updates, and operations exceeding risk budgets are denied before execution:
Code A settings file: the rules a tool reads before it acts.
policies:
- id: worker-agent-boundary
description: Guardrails for autonomous multi-agent workers
rules:
- id: block-unbounded-mutations
match:
connector_type: postgres
when: sql.unbounded_write == true
decision: deny
reason: Multi-agent workers must provide explicit primary keys in WHERE clauses.
- id: cap-modified-rows
match:
connector_type: postgres
when: sql.kind in ["update", "delete"] && sql.estimated_rows > 5
decision: ask
reason: Multi-agent mutations affecting more than 5 rows require human approval.
If an upstream agent hallucinated an expansive selector, the gate halts execution at the socket. PostgreSQL never sees the statement.
2. Physical read-back via write-ahead log decoding
Deedglass does not trust an agent’s self-reported execution summary. When an agent reports “Updated 1 subscription”, Deedglass reads the PostgreSQL Write-Ahead Log (WAL) through a dedicated logical replication slot.
It decodes the exact row diffs that committed to disk:
- The specific table and schema altered
- Pre-mutation values versus post-mutation values
- The exact count of affected relational rows
If the WAL reveals that 14 rows committed instead of the 1 row reported, Deedglass flags the mismatch immediately.
3. Causality chaining and Ed25519 records
Each action executed by an agent is sealed with an Ed25519 signature into a cryptographic, hash-chained record. Each record embeds the parent agent identifier, the on-behalf-of principal, the input arguments, and the verified storage diff.
Downstream agents are provided with the cryptographically sealed record hash. A downstream worker can verify that an upstream mutation was checked and committed before initiating secondary actions.
4. Automatic undo SQL generation
When a cascade is detected, Deedglass generates atomic undo SQL directly from the WAL pre-image diffs. The undo statements check that the affected rows still match the state left by the errant transaction before applying corrections.
If any row was touched by an unrelated process in the interim, PostgreSQL aborts the undo transaction, ensuring partial reversions never compound database corruption further.
Evaluating your agent swarm blast radius
Before deploying multi-agent swarms with write credentials in production, engineering teams must evaluate their blast radius. You can evaluate your setup locally using the open-source CLI:
Code Commands typed in a terminal. The text around it says what happens.
npx deedglass scan --postgres-dsn-env DATABASE_URL
The scan reads your project configuration, database roles, active MCP servers, and permission policies, scoring your setup from A to F according to the scan grade formula.
Deductions apply if worker agents share superuser credentials, if write paths operate without admission gates, or if database tables lack write-ahead log inspection.
Implementation checklist for agent swarms
To safeguard multi-agent architectures against compounding state corruption:
- Isolate agent credentials: Assign each worker its own API key and least-privilege database role. Never allow an orchestrator and executor to share database credentials.
- Deploy deterministic admission gates: Route all MCP servers and database tool calls through
deedglass mcp wrap. Block destructive statements and unbounded queries at the socket. - Inspect write-ahead logs: Enable logical decoding on production databases. Require verified WAL row diffs before downstream agents trigger external side effects.
- Enforce two-party approvals for high-value actions: Configure rules that require explicit human approval whenever mutations exceed predefined thresholds or touch sensitive schemas.
- Verify records offline: Use cryptographic record verification on air-gapped systems to maintain independent audit integrity without vendor lock-in.
Autonomous machine intelligence will inevitably experience hallucinations. The role of systems engineering is to ensure that a cognitive lapse in an upstream model cannot mutate physical reality unchecked.
Written with AI assistance and checked against our claims register.