Skip to content

Build a sequential workflow

Use a workflow when you know which steps should run and in what order. Your application calls each agent, passes its result to the next step, and decides how to handle failures. Each agent can have its own instructions, model, and tools.

For a short sequence, ordinary function calls are enough:

Define a Graph when you need dependencies across parallel branches or conditional edges. Use the vended graph tool when an agent should construct the graph.

This workflow extracts facts from incident notes, analyzes those facts, and writes a report. The agents receive the information they need through their prompts; your code fixes the order of the calls.

Before running the example, install the SDK and configure a model provider as shown in the quickstart.

YOUR CODE CALLS EACH AGENT IN TURN FACTS ANALYSIS Incident notes Extract facts researcher Analyze analyst Write report writer
from strands import Agent
def process_workflow(notes: str) -> str:
researcher = Agent(
system_prompt="Extract the facts in the supplied incident notes.",
callback_handler=None,
)
analyst = Agent(
system_prompt="Analyze the supplied facts. Distinguish causes from guesses.",
callback_handler=None,
)
writer = Agent(
system_prompt="Write a concise incident report from the supplied analysis.",
callback_handler=None,
)
facts = researcher(f"Extract facts from these notes:\n{notes}")
analysis = analyst(f"Analyze these incident facts:\n{facts}")
report = writer(f"Write a report from this analysis:\n{analysis}")
return str(report)
# Fictional notes keep the example independent of external data sources.
notes = (
"09:00: deployed version 2.3. 09:05: checkout errors increased. "
"09:12: rolled back to version 2.2. 09:15: error rate returned to normal. "
"Root cause has not been confirmed."
)
print(process_workflow(notes))

The researcher finishes before the analyst starts, and the analyst finishes before the writer starts. The report’s wording varies with the model; the order and inputs come from your application code. Creating the agents inside the function gives each run a fresh conversation.

If an agent call raises an error in this example, the function exits and later steps do not run. Catch errors around a step when your application should retry it, ask for input, or return a partial result. Check the returned content before continuing when a successful call can still produce an unsuitable answer.

A sequence of function calls does not add workflow persistence, a shared run status, or an overall deadline. Implement the controls your application needs.

You can instead use a Graph and its orchestration APIs. The supervised orchestrator example shows node timeouts, an approval gate, and cancellation, including the limits of timeout enforcement.

Use the vended graph tool when the agent should decide how to divide a request into subtasks. The model supplies nodes and dependency edges; the tool creates the agents, runs independent nodes in parallel, and passes upstream outputs to downstream nodes.

The tool accepts acyclic graphs. Configure it to constrain the graph’s size and the instructions, models, and tools available to its nodes. For a fixed sequence like the example above, keep the calls in your application. For cycles or conditional edges that your application defines, use the Graph SDK API.