Build Multi-Step Agent Workflows
Explore how to build multi-step agent workflows that adapt at runtime by using a planner-executor loop pattern. Understand how to design stateful systems where decision-making nodes select actions based on current observations and control execution flow dynamically until completion.
We'll cover the following...
In the lessons so far, every workflow we have built follows a predetermined structure. We know at design time which nodes will run and in what order. The conditional edges choose between paths we defined, but we chose those paths ahead of time. The graph cannot invent a new path on its own.
Agent workflows are different. An agent is a system that decides what to do next based on what it observes, and that decision can produce different sequences of steps depending on the situation. The classic pattern for this is the planner-executor loop: one node reasons about the current state and decides on an action, and another node executes that action and writes the result back to state. The planner then observes the result and decides what to do next. This cycle repeats until the agent decides it is done.
This pattern is where LangGraph graphs start to feel qualitatively different from a fixed pipeline. The graph structure stays the same. The execution sequence changes with every input.
The decide-act-observe loop
The core of any agentic workflow is a three-step cycle.
Decide: The planner node reads the current state, including any prior observations, and decides on the next action. For a research assistant, the decision might be: “search for background information”, “look up a specific fact”, “synthesize what we have so far”, or “we are done, write the final answer”.
Act: The executor node receives the action label from state and carries it out. It might call a search tool, run a calculation, query a knowledge base, or call the model with a specific prompt. The result is written to state as an observation.
Observe: The planner reads the new observation on the next cycle. It has more information now than it did on the previous pass. Its next decision reflects what was learned.
The graph encodes this cycle as a loop. The planner’s output drives a conditional edge back to the executor, and the executor’s output drives an edge back to the planner. A stop condition in the planner ends the loop when it decides no more actions are needed.
What we are building
We will build a research assistant that answers user questions about a product by planning which knowledge areas to look up, executing those lookups one at a time, and synthesizing the results into a final answer when it has enough information.
The planner can issue one of four action labels: search_pricing, search_policies, search_technical, or done. Each lookup action retrieves information from a mock knowledge base. When the planner labels the action as done, the graph exits the loop and writes the final synthesized answer.
State design
The state schema carries three distinct types of data: the ...