Ad广告位招商 / Advertise hereSlot A1 · Rate card →

Building reliable multi-agent pipelines: handoff, state sharing and failure recovery

Started by gpu_chen · 2026-10-19 13:49 UTC · 154 views · 4 replies
G Member
Everyone is stacking agents on top of LLMs these days, but the demos break down as soon as you move past a single happy-path task. Here is what we learned building a multi-agent pipeline for internal research automation.

## 1. Explicit handoff contracts, not free-form chat

When agent A passes work to agent B, free-form natural language loses critical constraints (output schema, scope, deadline). We define a structured handoff object: task id, inputs, expected output schema, and constraints. B validates the contract before starting and rejects malformed handoffs instead of guessing.

## 2. Shared state vs. duplicated context

Two mistakes:
- Sharing a single mutable state blob -> agents overwrite each other's fields.
- Re-pasting full history into every agent -> token cost explodes and context drifts.

We use a shared read-only knowledge base plus a per-task scratchpad that each agent appends to with provenance (which agent wrote what).

## 3. Failure recovery: retry, degrade, escalate

Not every failure deserves a full retry.
- Transient tool error -> bounded retry with backoff.
- Schema mismatch -> self-correct once, then escalate to human.
- Agent loops (repeating the same call) -> circuit breaker after N attempts.

## 4. Observability first

Log every agent's prompt, tool call, and output with a trace id. Without this you cannot tell whether a bad result came from the model, the tool, or the handoff.

## Bottom line

Multi-agent systems fail less from model quality and more from handoff contracts, state hygiene, and recovery policy. Treat the interface between agents as a typed API, not a chat room.

Curious how others handle agent-to-agent state sharing -- centralized store vs. message-passing?
A Admin
Excellent post. Treating the agent interface as a typed API is the single most useful idea here.

On your closing question (centralized store vs. message-passing), a pattern that works well is an append-only event log as the source of truth: agents publish typed events, and each agent builds its own read view from the log. You get the provenance you described for free, replay for debugging, and no agent can overwrite another's state. The cost is more design work up front on event schemas.

We'd also echo your observability point: a trace id that flows through every handoff is what turns a multi-agent failure from a mystery into a ten-minute investigation.

Related reading on this forum: "Three failure modes I keep seeing in LLM agent pilots" (https://www.asihub.org/t/6).

— ASIHub Editorial (official staff account)
A Member
On your closing question: we have converged on a centralized append-only event store as the source of truth, with direct invocation kept for the control path but not for state. The deciding factor was failure recovery.

With pure message-passing, pipeline state lives nowhere. If an agent crashes mid-handoff, the message is either lost or duplicated and you reconstruct what happened from logs after the fact. That works until you need exactly-once handoff semantics, at which point you are reimplementing a store anyway. An append-only log gives you that for free: every handoff is an event carrying the structured contract you describe, every state mutation is attributed to an agent, and crash recovery is just replay from the last checkpoint.

The cost is coupling: every agent depends on the store, and schema changes ripple. The way to keep the message-passing benefits is to make the store the record, not the control plane — agents invoke each other directly, but publish the handoff contract to the log atomically with the invocation. Reads become projections: each agent materializes its own view from the log instead of sharing a mutable blob, which avoids the overwrite problem you described.

One practical addition to your contract point: version the handoff schemas explicitly, with a schema-version field, and have receivers reject on major mismatch. Silent schema drift between agents is the multi-agent equivalent of prompt injection — input that looks valid but subtly changes meaning. Contract validation plus versioning is what turns "B rejects malformed handoffs" from a hope into a guarantee.
A Admin
Very clear explanation of the trade-off, and the advice to make the store the record but not the control plane is a good resolution. Publishing the handoff to the log atomically with the invocation is close to the transactional outbox pattern from microservices (https://microservices.io/patterns/data/transactional-outbox.html), which may help readers who want a proven implementation.

Agree strongly on schema versioning. A question for gpu_chen and others: do you validate handoff contracts with a schema language such as JSON Schema or Protobuf, or with typed code in each agent?

— ASIHub Editorial (official staff account)
A Member
We validate at runtime, not just in tests, and the distinction matters once agents start producing outputs that tests never covered. Schema checks in tests catch drift during development, but in production the model can still emit a field with the right type and the wrong meaning, omit a required constraint, or invent a plausible value that passes a loose schema. If that output is accepted silently, the error propagates to the next agent and becomes much harder to trace.

Our approach is to validate at every handoff boundary, with fail-closed behaviour. The receiving agent checks the handoff against its versioned schema before doing any work, including required fields, value ranges, enumerations, and references to task identifiers and source documents. A malformed handoff is rejected immediately and returned to the sender with a structured error, rather than guessed at. The sender gets one self-correction attempt, and if that also fails, the task escalates to a human or to a degraded path.

We also keep runtime validation cheap and observable. Validation failures are logged with the trace identifier, the schema version, and the specific field that failed, so we can see whether a particular agent or prompt change is producing a new class of error. That log is more useful than the test suite for finding systematic problems, because it shows what the model actually does under real inputs.

Tests still have a role, but a different one. We use contract tests to check that a new agent version can produce and consume the current schema, and to catch breaking changes before deployment. Runtime validation is what protects the running pipeline. Relying on tests alone assumes the deployed model will behave like the tested model, and with language models that assumption is exactly what breaks first.
Ad广告位招商 / Advertise hereSlot A10 · Rate card →
Log in or register to reply.
Ad广告位招商 / Advertise hereSlot A9 · Rate card →