Home > Articles

This chapter is from the book

When Should You Use Workflows Versus Agents?

So, what’s the takeaway from the last case study? Sure, you can just set an agent loose with some tools and let it figure things out for itself, but that’s not usually the most efficient (or cheapest) approach. Here’s how I would break it down:

  • Workflows are the right move when you know the pathway ahead of time and don’t expect many unforeseen edge cases. If you have a repeatable task and clear logic, just build the steps directly.

  • Workflows require more upfront coding. You’ll need to define all the steps, nodes, and edges; handle the branching logic; and think about edge cases yourself. But once it’s built, the solution will be efficient.

  • Workflows let you bake in efficiency tricks, such as optimizing for the number of examples to use in a few-shot prompt, quality checks, or early exits when a step fails.

  • Agents are better at adapting on the fly. If your task isn’t always the same, or if you want the system to “figure it out” and possibly learn new shortcuts or solutions, agents can do that. But it might take a while for them to get truly good at it, assuming the system even has the ability to do so (the log_evidence tool was created by me, not inherent to the LLM).

  • Agents can easily switch between chatting and doing work. Need an AI system that can both explain something to a user and then go run a few database queries? Agents are built for this kind of flexible, multi-step interaction.

Bottom line: If you want pure efficiency and can define the process, go with a workflow. If you want flexibility and potential for the system to “learn” over time (and you’re okay with some bumps along the way), let an agent loose with the right tools. When in doubt, test, test, test! Develop some hypotheses, set up a testing environment, and experiment to your heart’s content.

We are just getting started with agents and our experiments with them. Next, we’ll look at a tricky situation: What if we need multiple agents over a period of time to tackle a complex long-term goal?

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.