AI Engineer World's Fair 2025

Agents vs Workflows: Why Not Both?

Sam Bhagwat· Founder, Mastra15:37

Loading slides…

Read the talk

Agents vs Workflows: Why Not Both?

Agents choose what to do next; workflows make dependencies explicit. Combining them lets a system retain flexibility while adding control where reliability requires it.

From a talk by Sam Bhagwat

Before you start: Familiarity with LLM tool calls and basic asynchronous TypeScript will help with the examples.

Do agents make workflows obsolete?

Should you build an agent or a workflow—and why should you have to choose? Sam Bhagwat, a Gatsby co-founder and author of Principles of Building AI Agents, opens with the dispute behind that question. His talk puts the hot takes first and the practical design patterns afterward.

The starting point is Anthropic’s December article, Building effective agents, with its diagrams of agents, workflow routing, and orchestration. Then came an OpenAI guide that Bhagwat places in April, followed by criticism about both its novelty and its treatment of workflows. He characterizes its language as an “anti-workflow blast.” The matching discussion in A practical guide to building agents specifically criticizes declarative graph frameworks, a narrower target than workflows generally. Bhagwat recalls swyx responding with an emergency Latent Space post. The practical question underneath the controversy is whether model-directed execution should displace explicit orchestration.

Slide stating that the strongest reactions were around anti-workflow language, beside a highlighted excerpt headed “Declarative vs non-declarative graphs.”Open full source frame
The strongest reactions centered on anti-workflow language.
0:000:16
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

0:00 · section reference included

When provider advice becomes orthodoxy

Bhagwat’s first objection concerns who gets to define the right way to build. He directs it at OpenAI, then reaches back to a hallway conversation with Laurie Voss about the previous decade of web development: a developer in a prominent, public-facing role can turn a personal architectural preference into an ecosystem-wide prescription.

His example is the pressure certain Googlers put on web developers to “use the platform”—with an explicit qualification that he does not mean all Googlers. Bhagwat remembers that rhetoric functioning as an argument against React and in favor of technologies he found harder to use. Model providers now occupy a similarly influential position: their recommendations carry more weight than an ordinary developer’s preferences. That makes careful distinctions between useful patterns and supposedly mandatory approaches especially consequential.

Text slide describing years of lectures to web developers to “use the platform,” with a footnote saying “not all Googlers!”Open full source frame
Web developers were urged by certain Googlers to “use the platform.”
2:082:19
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

2:08 · section reference included

Make execution order readable

His second objection is more concrete: workflow frameworks should not make developers assemble nodes and edges just to express a process. Naming LangChain, Bhagwat calls that API style harmful—and draws on his own experience with Gatsby to explain why. Gatsby made GraphQL its default data-fetching pattern in 2017. Some users loved it; others wanted a React metaframework without having to adopt that additional way of working, and chose alternatives. GraphQL could be a good technology while still being the wrong requirement to impose on every user.

Graph-oriented workflow APIs give him the same concern. His objection is the learning burden placed on the whole team, not just the person who initially wires up the application. In the alternatives he shows, Mastra uses fluent workflow syntax and Inngest expresses a sequence whose control flow is visible as you read downward. The code’s reading order should help reveal its execution order. Separately declaring nodes and connecting edges can obscure that relationship.

3:393:50
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

3:39 · section reference included

From architectural patterns to turns and dependencies

A readable API is only part of the problem. Developers also need a shared vocabulary for the arrangements they build. Bhagwat introduces that need through Christopher Alexander, the Berkeley architect associated with A Pattern Language. Published in 1977, the book catalogs 253 patterns spanning towns, buildings, and construction. Bhagwat contrasts what he describes as architects’ cooler reception with software engineers’ enthusiasm, placing the latter roughly in the late 1980s and early 1990s. His concern for agent engineering is that a similarly accepted glossary of patterns has not yet emerged.

He credits Nick and Zach’s previous-day Mastra workshop for the definition slides, then supplies two everyday mental models. An agent resembles a turn-based game: the user takes a turn, the agent responds, and the agent may take additional turns or make tool calls. A workflow resembles the rules behind a Civilization technology tree. In his examples, bronze working precedes iron working, and metallurgy precedes gunpowder. The essential property is a dependency: step B cannot happen until step A has happened. A data pipeline extends that relationship through A → B → C → D → E.

The two starting points lead to different capabilities:

Starting pointCapabilities that follow
Messages and turnsConversation threads and memory
Steps and dependenciesBranches, parallelism, conditions, and loops
Managed workflow executionSuspension, resumption, and replay

These are complementary ways to organize an application. Messages preserve an interaction’s context; workflow dependencies express when work may proceed and how execution can continue.

6:206:33
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

6:20 · section reference included

Add control where behavior becomes unreliable

Ordinary code can already execute A, then B, then C, then D. Why introduce a workflow framework? In AI applications, nondeterminism makes it especially useful to trace what happened and inspect how execution reached a result. Bhagwat emphasizes this by calling tracing “10X as important”; the phrase expresses urgency rather than a measured comparison. Instrumentation and replayability help make a variable process inspectable.

Slide titled “Why workflows now?” explaining that instrumentation, tracing, and replayability matter more in agentic applications because LLMs are nondeterministic.Open full source frame
Nondeterministic LLMs increase the need for instrumentation, tracing, and replayability.

Choose flexibility and control separately for each part of the application. You can begin by giving an agent freedom to decide, then add structure where its behavior goes off the rails. This turns the agents-versus-workflows question into a local architectural decision: which operation benefits from discretion, and which needs a more constrained process?

Bhagwat describes a whiteboarding problem involving a large PDF of medical documentation. The application is trying to work through symptoms but is not extracting the right information. He proposes splitting one LLM call into multiple focused calls; he reports no measured accuracy improvement. The proposed change separates the work so that each call can concentrate on a particular symptom.

In TypeScript, that decomposition can be expressed by passing the same document through a focused extraction operation for each symptom:

typescript

type SymptomEvidence = {
  symptom: string;
  passages: string[];
};

type ExtractSymptom = (input: {
  documentText: string;
  symptom: string;
}) => Promise<string[]>;

async function extractSymptoms(
  documentText: string,
  symptoms: readonly string[],
  extractSymptom: ExtractSymptom,
): Promise<SymptomEvidence[]> {
  const results: SymptomEvidence[] = [];

  for (const symptom of symptoms) {
    const passages = await extractSymptom({ documentText, symptom });
    results.push({ symptom, passages });
  }

  return results;
}

This procedure makes one focused call per symptom entry and retains the symptom associated with each result. The architectural question comes first: identify the unreliable operation, then decide what structure could improve it. Bhagwat recommends explaining the architecture to a colleague and drawing it on a whiteboard; making the dependencies visible can expose a better way to combine the primitives.

9:339:41
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

9:33 · section reference included

Use agents and workflows inside each other

The composition rules are small. Agents call tools; workflows execute steps. Either primitive can occupy either role:

CompositionWhat it enables
Agent as a workflow stepModel-directed work inside a structured process
Workflow as an agent toolA structured operation the agent can choose to invoke
Agent as an agent toolDelegation to a specialist
Workflow as a workflow stepA larger process assembled from smaller processes

The useful design space comes from combining these arrangements, rather than choosing one primitive for the entire application.

The agent supervisor pattern uses the third arrangement. An orchestrator agent calls specialist agents as tools; Bhagwat’s example includes a research agent and a summary agent. The supervisor provides the point of coordination, while specialist agents perform the delegated work. His Mastra examples are intentionally small enough to fit in a slide panel: the point is that simple primitives can yield understandable combinations. These are historical API illustrations; the TypeScript example above expresses the decomposition directly without reconstructing the slide’s framework calls.

Slide titled “Agent supervisor,” with a central green node connected by arrows to three surrounding nodes and a code panel on the right.Open full source frame
An agent supervisor diagram alongside a code example.
11:4311:54
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

11:43 · section reference included

Structured tools, changing toolsets, and nested processes

For workflows as tools, Bhagwat switches to trip planning: plan a location, check the weather, then plan the trip. Those operations may each contain a more complex workflow. Exposing them as tools lets an agent iterate and decide while the invoked workflows retain their internal structure. He also names workflows that perform agent handoffs, extending the idea of structured execution coordinating agents.

Dynamic tool injection changes which tools an agent receives at a particular moment. Bhagwat warns that agents can begin failing when given double-digit numbers of tools, and recommends selecting tools for the current task and stage of execution. The mechanism is to make the available set relevant to what the agent is doing now, rather than expose every capability throughout the interaction.

Nested workflows apply the same composition principle to processes: a workflow becomes a step inside another workflow. Bhagwat closes the presentation by emphasizing that the value comes from combining these patterns appropriately. Production applications accumulate details, so their agentic workflows will too. The architecture must accommodate those details through combinations of tools, steps, agents, and workflows.

12:5613:05
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

12:56 · section reference included

Keep the system that meets its requirements

The audience immediately tests that advice against a working system. A questioner first asks whether a deep-research agent should be combined with a workflow rather than replace it. They then explain that their workflow already works very well with 20 tools, despite arguments that orchestration is unnecessary. Bhagwat restates it as an agent working well with 20 tools. Neither account supplies an evaluation metric, but the example makes clear why the earlier tool-count warning cannot be treated as a fixed limit.

His response is to keep using the system if it meets its requirements. Agent engineering is a “community of practice” more than a “community of theory.” If a working implementation contradicts a theoretical prescription, that can reveal a weakness in the theory. In a young field, practice is evolving faster than the explanations that attempt to organize it.

For follow-up, Bhagwat says he is available around the conference and uses @calcSam: CALC as in calculator, SAM as in his name.

14:1014:20
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

14:10 · section reference included

Resources

From the talk

  • Anthropic's explanation of workflows, autonomous agents and composable orchestration patterns.

  • OpenAI's guide to agent design, tools, orchestration and guardrails, including its discussion of declarative graphs.

  • Introduction to the 1977 architectural pattern collection, comprising 253 patterns across towns, buildings and construction.

Updates since the talk

Transcript download
Full transcript

Loading transcript…