DEV Community

Cover image for Why AI Agents Need Workflows, Not Just Prompts
Swrly
Swrly

Posted on • Originally published at swrly.com

Why AI Agents Need Workflows, Not Just Prompts

You build an agent. You give it a system prompt, a few tools, and access to an API. It works. You show the demo. Everyone is impressed. Then you try to put it in production and everything falls apart.

This is the story of almost every team that has tried to ship AI agents in the last two years. The single-agent, single-prompt pattern is a great starting point. It is a terrible architecture for anything that needs to be reliable.

The Single-Agent Ceiling

A single-prompt agent is essentially a loop: take input, think, call tools, return output. Frameworks like LangChain and CrewAI make this loop easy to set up. You can get a working prototype in an afternoon. The problem is that prototypes and production systems have fundamentally different requirements.

A prototype needs to work once. A production system needs to work every time, fail gracefully when it cannot, tell you what happened either way, and do all of this at scale without anyone babysitting it.

Single-prompt agents cannot meet these requirements because they operate as monoliths. One prompt does everything: reasoning, tool selection, error handling, output formatting. When the task gets complex, you end up stuffing more instructions into the prompt, which makes the agent less reliable, not more. You are fighting the context window instead of designing for the problem.

What Breaks in Production

Here are the concrete failure modes we see when teams try to run single-agent architectures in production.

No retry boundaries. When a single agent fails at step 4 of a 7-step task, you have two options: restart from scratch or accept the failure. There is no way to retry just the step that failed because there are no steps. It is one big prompt execution. For a workflow that takes 3 minutes and costs $0.50 in tokens per run, restarting from scratch on every transient error gets expensive fast.

Context window pollution. An agent that fetches data, analyzes it, makes a decision, and takes action is doing four distinct jobs in one context window. The raw data from the fetch step consumes tokens that the analysis step needs. The analysis output stays in context when you only need the decision. By the time you get to the action step, you are working with a bloated context that makes the agent slower and less focused.

No observability. When a single agent produces bad output, you get one blob of text and a list of tool calls. Which reasoning step went wrong? Was it the data gathering? The analysis? The decision logic? You have to read through the entire trace manually and hope you can spot where the reasoning diverged. For a team running hundreds of agent executions per day, this does not scale.

No branching logic. Real workflows have conditions. If the code review passes, merge the PR. If it fails, post a comment and notify the author. If the CI is still running, wait and check again. A single-prompt agent handles this through in-context reasoning, which means the branching logic is implicit, untestable, and invisible. You cannot look at a system diagram and understand the flow because there is no diagram. There is just a prompt.

No handoffs. Different tasks require different expertise. A data analysis task needs different tools, different context, and a different system prompt than a code generation task. When one agent does both, it is mediocre at each. When you split them into separate agents, you need a way to pass context between them. A single-agent architecture has no concept of handoffs.

Why Workflows Change the Equation

A directed workflow addresses each of these failure modes by making the implicit structure of your agent's task explicit.

Instead of one agent doing everything, you have multiple specialist agents connected by edges in a graph. Each agent has a clear role, a focused prompt, and access to only the tools it needs. The workflow engine handles routing, retries, and context passing between them.

This is not a new idea. Software engineering figured this out decades ago with microservices, Unix pipes, and CI/CD pipelines. The principle is the same: small, focused units of work composed into larger systems. The composition layer gives you the observability, retry logic, and branching that the individual units do not need to know about.

With a workflow-based architecture, you get retry boundaries at every node. If the data fetch agent fails, retry it without re-running the analysis. You get isolated context windows. Each agent sees only what it needs, not the entire conversation history. You get visual observability. Every node in the graph has a status, a duration, an input, and an output. You can see exactly where things went wrong. You get explicit branching. Condition nodes route execution based on upstream outputs, and the branches are visible in the graph. And you get composable handoffs. Agent A's output becomes Agent B's input through a well-defined interface.

What This Looks Like in Practice

Consider a PR review workflow. Without orchestration, you might write a single agent with a prompt like: "Review this PR. Check the code quality, verify the tests pass, check for security issues, and either approve it or request changes."

That works for simple PRs. But for a real codebase, you want separate concerns. A code quality reviewer that focuses on style, patterns, and maintainability. A security scanner that checks for known vulnerability patterns. A test coverage analyzer that verifies the changed code is tested. And a decision agent that takes all three reviews and decides whether to approve, request changes, or flag for human review.

In Swrly, this is a four-agent workflow with a join node. The three reviewers run in parallel. The join node waits for all three to complete. The decision agent receives their combined output and makes the final call. A condition node routes the result: approve the PR, post review comments, or send a Slack message to the team lead.

Each agent is focused. Each agent can be tested independently. Each agent can be swapped out without touching the others. And when the security scanner takes too long, you can see it immediately in the execution overlay instead of wondering why the whole thing is slow.

The Composability Unlock

The real power of workflows is not just reliability. It is composability.

Once you have a library of well-defined agents, you can compose them into new workflows without writing new code. Your PR review agents can be reused in a deployment pipeline. Your data analysis agent can feed into a reporting workflow or a monitoring alert. Your Slack notification agent works in every workflow that needs to notify someone.

This is the same unlock that microservices gave to backend engineering and that CI/CD pipelines gave to DevOps. Small, reusable units composed through a declarative graph. The individual pieces stay simple. The composition layer handles the complexity.

Single-prompt agents will always have a place for simple, one-shot tasks. But the moment you need reliability, observability, or composition, you need workflows. The ceiling is real, and the only way through it is to stop pretending that one prompt can do everything.

Top comments (0)