Back to Blog
Published:
Last Updated:
Recently Updated
AWS & Google Agent FrameworksChapter 1

Surviving Partial Failure in a 3,300-Call Agent Pipeline

8 min read
1,600 words
high priority
Mudassir Marwat

Mudassir Marwat

Founder & CEO, Cognilium AI

Surviving Partial Failure in a 3,300-Call Agent Pipeline — Cognilium AI

TL;DR

Two-tier retries, atomic DynamoDB chunk claims, and checkpoint-based cancellation — the failure-recovery layer that lets a multi-agent contract review pipeline finish even when 5% of LLM calls fail.

A contract review pipeline that fans out 1,000 to 3,300 LLM calls per document does not survive on retry-once-and-pray. Even at a 99.5% per-call success rate, a 3,300-call pipeline lands at roughly 0.995^3300 ≈ 0% chance of every call succeeding on the first try. Failures are not the exception — they are guaranteed.

The system this writeup describes scores legal contract clauses against twelve categories, runs eleven specialist analyst agents in parallel for each chunk, and ships findings into a Word add-in in real time. The orchestration runs on ECS Fargate; chunks fan out via SQS; per-chunk state lives in DynamoDB. The interesting part is not the orchestration — it is the failure-recovery layer underneath.

The two-tier retry

Tier one is internal exponential backoff inside the worker, with three attempts at 1s, 2s, 4s, capped at 30s total. This catches transient model errors — 429 rate limits, 5xx from Bedrock, network blips. Tier two is the SQS visibility timeout. If the worker crashes, OOMs, or hangs past 5 minutes, the message returns to the queue and a different worker picks it up. After three SQS deliveries the message lands in a dead-letter queue with full context for triage.

The split matters: tier one handles failures the worker can recover from; tier two handles failures the worker cannot. Combining them into one retry layer collapses observability — you cannot tell whether a slow chunk hit a model rate limit or whether the worker fell over.

Atomic chunk claim via DynamoDB conditional update

When tier two re-delivers a message, two workers may grab it. Without coordination they double-process the chunk and double-bill the customer. The conditional update fixes this with no locks: UpdateItem with ConditionExpression "attribute_not_exists(claimed_by) OR claim_expires_at < :now". Whichever worker writes first wins; the other catches ConditionalCheckFailedException and moves on. The claim has a TTL so a wedged worker does not block recovery indefinitely.

Checkpoint-based cancellation

When the customer cancels a 5-minute job at minute 3, you cannot just stop firing LLM calls — you have agents in flight, files being written to S3, downstream tasks queued. The checkpoint table records {job_id, stage, started_at, claimed_by} for every chunk-stage. Cancellation flips a job-level status to "cancelled". Each stage entry-point reads that status before doing work. Half-finished chunks land in the checkpoint table as "cancelled-at-stage-N" so the next operator knows exactly where things stopped.

What we measured

  • 22 chunks → 116 LLM calls per chunk → 154 seconds end-to-end on the happy path
  • Pre-fix: ~12% of jobs reported "incomplete" with one chunk silently missing
  • Post-fix: <0.5%, and every remaining failure is observable in the checkpoint table
  • DLQ retention: 14 days; alert threshold: 3 messages in 5 minutes

When this is overkill

If your agent pipeline is < 50 LLM calls per request, the per-call success rate carries you. If your pipeline is short-running (< 30 seconds), tier-two retries via SQS are slower than just letting the user retry. The pattern earns its complexity at the multi-thousand-call, multi-minute scale where partial failure is the default and full retry is too expensive.

Share this article

The work behind this series

Framework-agnostic agent deployment with memory persistence and observability.

Mudassir Marwat

Mudassir Marwat

Founder & CEO, Cognilium AI

Mudassir Marwat's argument is that ERP systems record decisions they never optimise.

Founder & CEO of Cognilium AI; 37 AI agents in production across four products; 4 production AI products built and operated; three clouds in production (AWSGCPAzure)
Agentic AIRAG → GraphRAG retrievalVoice AIMulti-Agent Orchestration

Frequently Asked Questions

Find answers to common questions about the topics covered in this article.

Internal exponential backoff catches transient model errors (rate limits, 5xx) within 30s without re-queuing. SQS visibility timeout catches deeper failures (worker crash, OOM) — the message reappears on the queue and a different worker picks it up. One tier handles known-recoverable; the other handles unknown.
UpdateItem with ConditionExpression "attribute_not_exists(claimed_by) OR claim_expires_at < :now". Two workers racing for the same chunk: only one succeeds, the other ConditionalCheckFailedException short-circuits and moves on. No locks, no Redis, no race-window.
A checkpoint table tracks {job_id, stage, status}. Each stage start reads the row; if status==="cancelled", the worker writes a final "cancelled-at-stage-N" row and exits cleanly. Half-finished work is recorded, not silently dropped.
Before the two-tier retry + atomic claim: ~12% of contracts failed with "incomplete results" — usually one chunk silently dropped. After: <0.5%, and the remaining failures are observable (the checkpoint table tells you exactly which chunk + which stage).
The pattern does. The atomic claim is "compare-and-swap on a row" — works in Postgres (SELECT ... FOR UPDATE SKIP LOCKED), Firestore (Transaction), or any CAS-capable store. The two-tier retry needs a queue with redelivery semantics — RabbitMQ, GCP Pub/Sub, Kafka with consumer-group offsets all qualify.

Still have questions?

Get in touch with our team for personalized assistance.

Contact Us

Still have a question this did not answer?

The person who wrote this article answers these. Describe your setup and what you are stuck on — you will get a straight answer, including where we think the approach is wrong.

Related Articles

Continue exploring related topics and insights from our content library.

Supervisor-Router on Google ADK with Per-Org Tool Registration
9 min
1
Mudassir Marwat
May 5, 2026

Supervisor-Router on Google ADK with Per-Org Tool Registration

Building a multi-tenant agent platform on Google ADK where the supervisor binds only the tools each org has paid for and integrated — without forking the agent definition per tenant.

words
Read Article
Multi-Agent Orchestration on AWS Bedrock AgentCore
9 min
2
Mudassir Marwat
May 4, 2026

Multi-Agent Orchestration on AWS Bedrock AgentCore

The supervisor + specialist pattern is the most reliable way to ship multi-agent systems on AWS — here is how to wire it, observe it, and bound its cost.

words
Read Article
Bias-Detection Alerts on a 4-Agent Candidate Evaluation Pipeline
7 min
3
Mudassir Marwat
May 5, 2026

Bias-Detection Alerts on a 4-Agent Candidate Evaluation Pipeline

A four-agent hiring pipeline is a regulated decision system. Continuous monitoring with alerts at the four-fifths-rule disparity-impact threshold.

words
Read Article

Explore More Insights

Discover more expert articles on AI, engineering, and technology trends.

Personalized for You

Curated content recommendations based on your current reading and interests.

Supervisor-Router on Google ADK with Per-Org Tool Registration — Cognilium AI
Trending
119%

Supervisor-Router on Google ADK with Per-Org Tool Registration

Same topic cluster: AWS & Google Agent Frameworks
Same author: Mudassir Marwat

Building a multi-tenant agent platform on Google ADK where the supervisor binds only the tools each org has paid for and integrated — without forking the agent definition per tenant.

Mudassir Marwat
9 min read
AWS & Google Agent Frameworks
Read Article
Trending
38%

Is your Dynamics 365 F&O ready for AI agents?

High priority content
Related topic cluster: Procure-to-Pay Agent Operations

Six checks in the order that blocks a project. Version and tier are binary. The two that stop most pilots are who may connect and who owns the identity.

Ali Ahmed
6 min read
Procure-to-Pay Agent Operations
Read Article
When to Mix SQS FIFO and Standard Queues in an Agent Pipeline — Cognilium AI
For You
112%

When to Mix SQS FIFO and Standard Queues in an Agent Pipeline

Same topic cluster: AWS & Google Agent Frameworks
Same author: Mudassir Marwat

FIFO for chunk ordering, Standard for parallel analysis fan-out. Why a single queue type for the whole pipeline is the wrong default, with the dead-letter and retry settings that make the split work.

Mudassir Marwat
7 min read
AWS & Google Agent Frameworks
Read Article
Diagram of supervisor-specialist multi-agent orchestration on AWS Bedrock AgentCore.
For You
109%

Multi-Agent Orchestration on AWS Bedrock AgentCore

Same topic cluster: AWS & Google Agent Frameworks
Same author: Mudassir Marwat

The supervisor + specialist pattern is the most reliable way to ship multi-agent systems on AWS — here is how to wire it, observe it, and bound its cost.

Mudassir Marwat
9 min read
AWS & Google Agent Frameworks
Read Article
Your multi-agent system has no brakes. You designed which agents exist and how they connect, but not the thing that decides when they stop, and in most systems nothing does. Control is emergent: it falls out of agents calling each other, so the system stops only when something runs out. Four ways control fails: non-termination, where the loop never ends; premature stop, where an agent's "done" was not actually done; mis-routing, where the task orbits and never lands; and no budget, where the rare tail run wrecks the bill. The fix is explicit control, not a smarter agent.
Trending
70%

Your Multi-Agent System Has No Brakes

Same author: Mudassir Marwat
Preferred author

A multi-agent system with no termination condition does not fail, it spends. The stopping criteria that actually hold, and the ones that only look like limits.

Mudassir Marwat
9 min read
Multi-Agent Systems in Production
Read Article
Your agents do not share a brain, they pass notes. Every hand-off compresses one agent's full working state into a message, and the next agent acts on that message alone, so the context one agent has is not the context the next one gets. Four ways a hand-off fails: context loss, where the sender drops what you needed; semantic drift, where the same words carry a different meaning; error laundering, where an uncertain guess arrives as a clean fact; and the coordination tax, where re-sending the accumulated context makes token cost grow quadratically. The fix is a shared store, not a better message.
Trending
68%

Your Agents Don't Share a Brain. They Pass Notes.

Same author: Mudassir Marwat
Preferred author

You wired the agents, and you learned the failures live in the seams between them. This chapter names the seam: it is the hand-off. When one agent finishes and the next begins, everything the first learned, its documents, its discarded hypotheses, its doubt, has to survive a trip through a single message, and the next agent acts on that message alone. Your agents do not share a brain, they share a mailbox, and every message is a lossy compression of what the sender knew. Four things go wrong: context loss, semantic drift, error laundering, and a coordination tax that grows with the square of the chain length. The fix is not a better prompt. It is a shared, typed store the agents read and write, plus hand-off contracts that make a bad message fail loudly instead of quietly.

Mudassir Marwat
10 min read
Multi-Agent Systems in Production
Read Article

Smart Recommendations

Our AI analyzes topic clusters, author expertise, and content relationships to surface the most relevant articles for you.

Topic Matching
Author Expertise
Content Quality
Personal Interests

Questions on this?

Talk to an engineer

Schedule a call