retries

Design smarter agent workflows by mapping retry logic before writing code

A failed agent doesn't have to mean a failed workflow.

3 min readTowards Data Science

Planning retry logic before writing a single line of code is the kind of discipline that separates reliable multi-agent systems from brittle experiments. A recent walkthrough from Towards Data Science demonstrates exactly this: using a Mermaid blueprint, Python dataclasses, and a simple `retryable` flag to decide when a failed agent should try again and when the task escalates to a human. It is a small, practical idea, and we believe it deserves more attention than it usually gets.

Too many teams treat agent orchestration as an afterthought, throwing retries into loops and hoping for the best. That approach works until it does not. When an agent fails on the third attempt and a downstream task has already consumed the partial output, you are left with corrupted state and no clear path to recovery. The blueprint-first method forces you to answer the hard questions before complexity sets in. What constitutes a permanent failure versus a transient one? At what point does persistence become waste? By mapping these decisions in a visual diagram and encoding them in structured data classes, you shift the conversation from "how do I code this" to "what should the system actually do." This aligns closely with the philosophy in Building Trust in AI Drafts with Engineering Precision, where non-determinism is treated as an engineering problem to be managed rather than a mystery to accept.

The retryable flag is the most instructive detail. It is deliberately binary: either the agent can retry, or it cannot. That simplicity forces clarity. If an agent queries an API that occasionally times out, the flag should be true and the retry count set to three. If an agent misinterprets a user's intent in a way that repeating the same prompt will not fix, the flag should be false and the task routed to a person. The blueprint then becomes a shared reference point for the entire team, not a piece of documentation nobody reads. This kind of explicit design is reminiscent of the work described in Why Machine-Verified Proofs Still Need Human Explanation: formal structure helps you reason about behavior, but human judgment determines when the structure applies.

The concrete takeaway is this: before you write a single agent, map the failure paths. Define what success looks like for each step, what counts as a recoverable error, and who or what handles the rest. A Mermaid diagram and a few dataclasses are cheap insurance against the kind of cascading failure that erodes trust in automated workflows. The question worth watching is how this pattern scales when you have dozens of agents and thousands of interdependent tasks. Does the retryable flag remain sufficient, or do you need probabilistic thresholds and dynamic escalation rules? The blueprint-first approach gives you a foundation to find out.

From Towards Data Science

A Mermaid blueprint, Python dataclasses, and a retryable flag decide when a failed agent tries again and when the task goes to a person.

The post How to Plan Retries for Multi-Agent Workflows Before You Write Code appeared first on Towards Data Science.

Read the original at Towards Data Science