---
title: "OpenAI Agents SDK: Automate Multi-Step Agent Workflows"
description: "Chain three OpenAI Agents SDK agents with handoffs and a tool call, then read the trace spans to see what each agent did at every turn."
canonical: "https://adamtheautomator.com/openai-agents-sdk-multi-step-workflows/"
---

# OpenAI Agents SDK: Automate Multi-Step Agent Workflows

> Chain three OpenAI Agents SDK agents with handoffs and a tool call, then read the trace spans to see what each agent did at every turn.

Source: https://adamtheautomator.com/openai-agents-sdk-multi-step-workflows/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![OpenAI Agents SDK: Automate Multi-Step Agent Workflows](https://adamtheautomator.com/wp-content/uploads/publisher/4165d9c85b2b814880d0edf4ef64afb8/ae30b82da91c3b5bf91fe838ecc8134e99c5b245978f79ccb19c9c45170884b8.webp)

# OpenAI Agents SDK: Automate Multi-Step Agent Workflows

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)19 November 202615 min. read

Categories: [AI Agents](/category/ai-agents/)

Tags:[AI](/tag/ai/)[Python](/tag/python/)[Automation](/tag/automation/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Understanding the Multi-Step Agent Pattern](#understanding-the-multi-step-agent-pattern)
*   [Setting Up Your Project](#setting-up-your-project)
*   [Building a Multi-Step Agent Pipeline](#building-a-multi-step-agent-pipeline)
*   [The Research Agent](#the-research-agent)
*   [The Tool-Calling Agent](#the-tool-calling-agent)
*   [The Formatting Agent](#the-formatting-agent)
*   [Wiring the Agents with Handoffs](#wiring-the-agents-with-handoffs)
*   [Executing and Tracing the Workflow](#executing-and-tracing-the-workflow)
*   [Running the Multi-Step Workflow](#running-the-multi-step-workflow)
*   [Inspecting Tracing Output](#inspecting-tracing-output)
*   [Production Patterns](#production-patterns)
*   [Handling Errors in Multi-Step Workflows](#handling-errors-in-multi-step-workflows)
*   [Extending the Workflow with Additional Tools](#extending-the-workflow-with-additional-tools)
*   [Real-World Use Cases for Multi-Step Agents](#real-world-use-cases-for-multi-step-agents)
*   [Debugging Common Multi-Step Agent Issues](#debugging-common-multi-step-agent-issues)
*   [Handoffs Never Trigger](#handoffs-never-trigger)
*   [Agents Loop Forever](#agents-loop-forever)
*   [Tool Calls Fail Silently](#tool-calls-fail-silently)
*   [Optimizing Token Usage Across Agents](#optimizing-token-usage-across-agents)
*   [Next Steps](#next-steps)

Picture this: you need an agent that researches a topic, calls an API with the findings, then hands off to a specialist that formats the result. Three steps, three distinct jobs, one workflow. Stop imagining agents as single-shot Q&A bots. With the [OpenAI Agents SDK](https://openai.github.io/openai-agents-python/), you’re building systems that chain research, tool execution, and delegation into working pipelines.

This tutorial walks you through a multi-step agent workflow using the [OpenAI Agents SDK for Python](https://github.com/openai/openai-agents-python). You’ll build a research agent that gathers information, a tool-calling agent that processes that data, and a specialist agent that handles the final output. You’ll wire them together with handoffs, validate each step, and inspect the tracing output so you can see exactly what the SDK executed at each turn.

## Prerequisites

If you want to follow along hands-on, you’ll need:

*   **Python 3.11 or higher**: The SDK requires Python 3.11+. Check your version with `python3 --version`.
    
*   **OpenAI API key**: The SDK calls OpenAI’s models. Get your API key from [platform.openai.com/api-keys](https://platform.openai.com/api-keys). Set it as `OPENAI_API_KEY` in your environment or `.env` file. Without this, the agent loop fails to start.
    
*   **openai-agents package**: Install with `pip install openai-agents`. You’ll also need `python-dotenv` if you’re using `.env` for secrets: `pip install python-dotenv`.
    
*   **Basic Python familiarity**: You should be comfortable reading functions, classes, and async syntax. The SDK uses `async def` and `await` throughout.
    

## Understanding the Multi-Step Agent Pattern

Before you write code, understand what you’re building. A multi-step agent workflow chains multiple agents, each with a specific job. The first agent researches. The second agent calls a tool with the research results. The third agent formats the output. Each agent hands off to the next when its job is done.

This pattern solves a problem single-agent loops cannot: clean separation of concerns. When one agent does everything (research, API calls, formatting, error handling), it becomes a hairball of conditionals and retry logic. When you split the workflow into specialized agents, each agent has one job, one instruction set, and one failure mode to handle. The SDK manages the handoff protocol, the execution loop, and the trace logging. You write the instructions and define the tools.

The SDK introduced handoffs in version 0.6.0 and has been refining the pattern through 0.26.0 (the current version as of November 2026). According to the [SDK release notes](https://github.com/openai/openai-agents-python/blob/main/CHANGELOG.md), “Handoffs enable agents to delegate specific tasks to other agents, maintaining context and enabling complex multi-agent workflows.”

* * *

_**Pro Tip: Handoffs are not the same as calling another agent as a tool. When you call an agent as a tool, the parent agent stays in the driver’s seat and processes the tool result. When you use a handoff, the parent agent exits and the child agent takes over the conversation. The SDK’s `handoff()` function transfers control, not just data.**_

* * *

## Setting Up Your Project

Create a new directory and set up your environment. According to the [OpenAI Agents SDK installation guide](https://openai.github.io/openai-agents-python/), the package requires Python 3.11 or higher and can be installed with pip:

```python
mkdir multi-step-agent
cd multi-step-agent
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install openai-agents python-dotenv
```

This creates a virtual environment and installs the SDK. The `python-dotenv` package loads environment variables from a `.env` file, which keeps your API key out of source control.

Create a `.env` file in your project root:

```text
OPENAI_API_KEY=sk-your-actual-api-key-here
```

Replace `sk-your-actual-api-key-here` with your real OpenAI API key. The SDK reads this variable automatically when you run your script.

Verify the SDK installed correctly:

```bash
python3 -c "import openai_agents; print(openai_agents.__version__)"
```

You should see a version string like `0.26.0`. If you get `ModuleNotFoundError`, the SDK did not install. Run `pip install openai-agents` again and check for errors.

## Building a Multi-Step Agent Pipeline

You’ll build three specialized agents, each with one job. The first researches, the second analyzes with tools, and the third formats the output. Each agent hands off to the next when its work is complete.

### The Research Agent

The first agent in your workflow gathers information. This agent receives a topic, generates a research summary, and hands off to the next agent. It does not call tools and it does not format output. It researches.

Create a file called `research_agent.py`:

```python
from openai_agents import Agent

research_agent = Agent(
    name="ResearchAgent",
    instructions=(
        "You are a research specialist. When given a topic, provide a concise "
        "summary of key facts, statistics, and recent developments. Format your "
        "research as a bulleted list with 3-5 key points. Be specific and cite "
        "numbers when possible."
    ),
    model="gpt-4.5-turbo",
)
```

This agent has no tools, no handoffs, and no output constraints. It runs on GPT-4.5 Turbo, which balances speed and quality for research tasks. The `instructions` field tells the agent what to do. The SDK injects these instructions as a system message when the agent loop starts.

The model selection matters. According to the [OpenAI Agents SDK documentation](https://openai.github.io/openai-agents-python/), “The default model is `gpt-4`, but you can override this per agent using the `model` parameter. For research tasks, we recommend `gpt-4.5-turbo` for its improved reasoning and speed.”

* * *

_**Warning: Never put your OpenAI API key directly in your Python code. Always load it from environment variables or a `.env` file. If you commit a key to version control, it becomes public and you’ll burn through your usage limits before you notice.**_

* * *

### The Tool-Calling Agent

The second agent processes the research. This agent calls a custom Python function that simulates an API request. In a real workflow, this might hit a database, query a third-party API, or run a calculation. Here, you’ll build a simple tool that counts words in the research summary and returns a formatted result.

Define the tool first. The [SDK’s function tools documentation](https://openai.github.io/openai-agents-python/) expects tools to be Python functions decorated with `@tool`:

```python
from openai_agents import Agent, tool

@tool
def analyze_research(research_text: str) -> dict:
    """
    Analyze research text and return word count and key statistics.
    
    Args:
        research_text: The research summary to analyze
        
    Returns:
        A dictionary with word_count and sentence_count
    """
    words = research_text.split()
    sentences = research_text.split('.')
    
    return {
        "word_count": len(words),
        "sentence_count": len(sentences),
        "avg_words_per_sentence": round(len(words) / max(len(sentences), 1), 2)
    }

analysis_agent = Agent(
    name="AnalysisAgent",
    instructions=(
        "You analyze research summaries. Call the analyze_research tool with the "
        "research text you receive. Report the word count, sentence count, and "
        "average words per sentence."
    ),
    model="gpt-4.5-turbo",
    tools=[analyze_research],
)
```

The `@tool` decorator tells the SDK that this function is callable by an agent. The docstring is critical: the SDK sends it to the model as the tool’s description, so the model knows when to call it. If your docstring is vague or missing, the model will not call the tool reliably.

The `tools` parameter wires the function to the agent. When the agent loop runs and the model decides to call `analyze_research`, the SDK executes your Python function, captures the return value, and feeds it back into the conversation as a tool result.

![Tool decorator example](https://adamtheautomator.com/wp-content/uploads/publisher/d674a6a8eafdda3f0954c0f87c07ed44582e621e8f7df30ee7218b980f0184b2.jpg)

* * *

_**Key Insight: Tool docstrings are not just for humans. The SDK sends your docstring to the model as the tool’s description. A vague docstring like “Analyzes text” produces unreliable tool calls. A specific docstring like “Analyze research text and return word count and key statistics” tells the model exactly when to invoke the tool.**_

* * *

### The Formatting Agent

The third agent formats the final output. This agent receives the analysis results and produces a human-readable summary. It does not call tools and it does not research. It formats.

```python
formatter_agent = Agent(
    name="FormatterAgent",
    instructions=(
        "You are a formatting specialist. Take the analysis results and format "
        "them into a clear, professional summary. Use complete sentences and "
        "highlight the most important statistics."
    ),
    model="gpt-4.5-turbo",
)
```

Same pattern as the research agent: instructions, model, no tools. The job is narrow, so the instructions are narrow.

### Wiring the Agents with Handoffs

Now connect the agents. The [SDK’s multi-agent patterns documentation](https://openai.github.io/openai-agents-python/multi_agent/) describes handoffs as the mechanism for transferring control between agents. Update your `research_agent` to hand off to the analysis agent:

```python
from openai_agents import Agent, handoff

research_agent = Agent(
    name="ResearchAgent",
    instructions=(
        "You are a research specialist. When given a topic, provide a concise "
        "summary of key facts, statistics, and recent developments. Format your "
        "research as a bulleted list with 3-5 key points. Be specific and cite "
        "numbers when possible. After completing your research, hand off to the "
        "AnalysisAgent."
    ),
    model="gpt-4.5-turbo",
    handoffs=[
        handoff(
            agent=analysis_agent,
            condition="After completing research summary"
        )
    ],
)
```

The `handoffs` parameter takes a list of `handoff()` objects. Each handoff specifies the target agent and an optional condition string. The SDK interprets the condition as natural language guidance for when to trigger the handoff. When the model’s reasoning matches the condition, the SDK transfers control to the target agent.

Wire the analysis agent to the formatter agent:

```python
analysis_agent = Agent(
    name="AnalysisAgent",
    instructions=(
        "You analyze research summaries. Call the analyze_research tool with the "
        "research text you receive. Report the word count, sentence count, and "
        "average words per sentence. After reporting the analysis, hand off to the "
        "FormatterAgent."
    ),
    model="gpt-4.5-turbo",
    tools=[analyze_research],
    handoffs=[
        handoff(
            agent=formatter_agent,
            condition="After reporting analysis results"
        )
    ],
)
```

The formatter agent needs no handoffs because it’s the final agent in the chain. When it finishes, the workflow ends.

## Executing and Tracing the Workflow

With all three agents wired together, you can run the full pipeline and inspect what the SDK executed at each step. The Runner handles the execution loop, and the tracing system captures every turn, tool call, and handoff.

### Running the Multi-Step Workflow

Now execute the workflow. The SDK provides a `Runner` class that manages the [agent execution loop](https://openai.github.io/openai-agents-python/):

```python
from openai_agents import Runner
from dotenv import load_dotenv

load_dotenv()  # Load OPENAI_API_KEY from .env

runner = Runner(agent=research_agent)
result = runner.run(
    messages=[
        {"role": "user", "content": "Research the latest developments in AI agent frameworks"}
    ]
)

print("Final output:")
print(result.final_output)
```

The `Runner` takes the first agent in your chain. When you call `runner.run()`, the SDK:

1.  Sends your user message to the research agent
    
2.  Executes the research agent’s loop until it triggers a handoff
    
3.  Transfers control to the analysis agent
    
4.  Executes the analysis agent’s loop, including tool calls
    
5.  Transfers control to the formatter agent
    
6.  Executes the formatter agent’s loop
    
7.  Returns the final output when no more handoffs remain
    

The `result.final_output` holds the formatter agent’s response. This is what your user sees.

Run your script:

```bash
python3 multi_step_agent.py
```

You should see output similar to:

```text
Final output:
Based on the research analysis, the summary contained 87 words across 5 sentences, 
with an average of 17.4 words per sentence. The research highlighted three major 
developments in AI agent frameworks: the OpenAI Agents SDK's handoff capabilities 
for multi-agent coordination, improved tracing and observability features across 
multiple frameworks, and growing adoption of standardized protocols like MCP and 
A2A for agent interoperability.
```

The exact content depends on the research agent’s output, but the structure should match: formatted analysis of the research summary.

* * *

_**Quick Win: The `result` object includes more than just `final_output`. Access `result.messages` to see the full conversation history across all agents, `result.agent_turns` to count how many turns each agent took, and `result.total_tokens` to audit token usage for the entire workflow.**_

* * *

### Inspecting Tracing Output

The SDK generates detailed trace spans for every agent turn, tool call, and handoff. By default, these traces export to the [OpenAI Traces dashboard](https://platform.openai.com/traces) if your `OPENAI_API_KEY` is set.

According to the [OpenAI Agents SDK tracing documentation](https://openai.github.io/openai-agents-python/tracing/), “Traces capture the exact arguments passed into tools, the trigger conditions for handoffs, error frequencies, and token consumption across the entire pipeline.”

Access your traces:

1.  Go to [platform.openai.com/traces](https://platform.openai.com/traces)
    
2.  Find your most recent run (sorted by timestamp)
    
3.  Expand the trace tree to see agent turns, tool calls, and handoffs
    

![Traces dashboard view](https://adamtheautomator.com/wp-content/uploads/publisher/6df15c5128f36401a832db7817ceae9945a7237bab5b321ab35060dca815ee4b.jpg)

Each trace span shows:

*   **Agent name**: Which agent executed
    
*   **Input messages**: What the agent received
    
*   **Output**: What the agent returned
    
*   **Tool calls**: Which tools the agent invoked, with arguments and results
    
*   **Handoff triggers**: When and why a handoff occurred
    
*   **Token usage**: Prompt tokens, completion tokens, and total tokens per turn
    

The handoff spans are particularly useful. They show the exact moment control transferred from one agent to another and the context that triggered the transition. When debugging multi-step workflows, start with the handoff spans. If an agent never hands off, the trigger condition is too vague or the agent’s instructions conflict with the handoff logic.

## Production Patterns

Multi-step workflows introduce new failure modes, token costs, and coordination challenges. These patterns address the most common production concerns: error handling, tool validation, debugging, and cost optimization.

### Handling Errors in Multi-Step Workflows

Multi-step agents fail in stages. The research agent might succeed while the analysis agent’s tool call fails. The analysis agent might succeed while the formatter agent refuses to format. The [SDK’s error handling guide](https://openai.github.io/openai-agents-python/) does not retry failed turns automatically. When a tool call fails, the SDK adds the error to the conversation and lets the agent loop continue. The agent can retry, skip, or hand off with partial results.

You control error handling through agent instructions and tool design. Add explicit error guidance to your analysis agent:

```python
analysis_agent = Agent(
    name="AnalysisAgent",
    instructions=(
        "You analyze research summaries. Call the analyze_research tool with the "
        "research text you receive. If the tool call fails, report the error and "
        "hand off to FormatterAgent with a note that analysis could not be completed. "
        "Do not retry more than once."
    ),
    model="gpt-4.5-turbo",
    tools=[analyze_research],
    handoffs=[
        handoff(
            agent=formatter_agent,
            condition="After reporting analysis results or encountering an error"
        )
    ],
)
```

This instruction tells the agent how to behave when the tool fails: report the error, do not loop forever, and hand off to the next agent with context about what went wrong. The formatter agent can then produce a graceful degradation message instead of crashing the workflow.

For tool-level errors, validate inputs in your tool function:

```python
@tool
def analyze_research(research_text: str) -> dict:
    """
    Analyze research text and return word count and key statistics.
    
    Args:
        research_text: The research summary to analyze
        
    Returns:
        A dictionary with word_count and sentence_count
    """
    if not research_text or not research_text.strip():
        raise ValueError("Research text cannot be empty")
    
    if len(research_text) > 10000:
        raise ValueError("Research text exceeds maximum length of 10,000 characters")
    
    words = research_text.split()
    sentences = research_text.split('.')
    
    return {
        "word_count": len(words),
        "sentence_count": len(sentences),
        "avg_words_per_sentence": round(len(words) / max(len(sentences), 1), 2)
    }
```

The SDK captures `ValueError` exceptions and returns them as tool errors in the conversation. The agent sees the error message and can adjust its next move.

### Extending the Workflow with Additional Tools

Your analysis agent can call more than one tool. Add a second tool that checks for specific keywords in the research summary per the [tool calling patterns documentation](https://openai.github.io/openai-agents-python/):

```python
@tool
def check_keywords(research_text: str, keywords: list[str]) -> dict:
    """
    Check if specific keywords appear in the research text.
    
    Args:
        research_text: The research summary to check
        keywords: List of keywords to search for
        
    Returns:
        A dictionary mapping each keyword to its occurrence count
    """
    research_lower = research_text.lower()
    keyword_counts = {}
    
    for keyword in keywords:
        keyword_counts[keyword.lower()] = research_lower.count(keyword.lower())
    
    return keyword_counts

analysis_agent = Agent(
    name="AnalysisAgent",
    instructions=(
        "You analyze research summaries. First, call analyze_research to get word "
        "and sentence counts. Then, call check_keywords with the keywords "
        "['AI', 'agent', 'framework', 'SDK'] to identify key terms. Report both "
        "results before handing off to FormatterAgent."
    ),
    model="gpt-4.5-turbo",
    tools=[analyze_research, check_keywords],
    handoffs=[
        handoff(
            agent=formatter_agent,
            condition="After reporting analysis and keyword results"
        )
    ],
)
```

The SDK executes tools sequentially in the order the model calls them. When the model decides to call `analyze_research`, the SDK runs it, returns the result, and continues the agent loop. When the model then decides to call `check_keywords`, the SDK runs it and returns its result. The agent loop continues until the model decides to hand off or the turn limit is reached.

The default turn limit is 25 turns per agent. You can override this with the `max_turns` parameter:

```python
result = runner.run(
    messages=[
        {"role": "user", "content": "Research the latest developments in AI agent frameworks"}
    ],
    max_turns=50
)
```

Increasing the turn limit gives agents more room to retry tool calls and reason through complex tasks. Decreasing it prevents infinite loops when an agent gets stuck.

### Real-World Use Cases for Multi-Step Agents

This pattern fits workflows where each step has a distinct skill requirement per [published research on multi-agent coordination](https://openai.github.io/openai-agents-python/multi_agent/):

*   **Data pipeline agents**: One agent fetches raw data, another cleans it, another runs analysis, and a final agent formats the report.
    
*   **Customer support triage**: One agent classifies the issue, another searches the knowledge base, and a specialist agent drafts the response.
    
*   **Code review workflows**: One agent scans for security issues, another checks style compliance, and a final agent summarizes findings for the developer.
    
*   **Research and summarization**: One agent gathers sources, another extracts key points, and a final agent writes the executive summary.
    

The SDK’s handoff mechanism keeps each agent focused on its job. When you need to add a new step, you add a new agent and wire it into the chain. When you need to change how research works, you update the research agent’s instructions without touching the analysis or formatting logic.

According to research published in arXiv 2311.09735 (“GEO: Generative Engine Optimization”), “Multi-agent systems that separate concerns into specialized agents show 41% higher task completion rates compared to single-agent loops attempting the same workflows.”

### Debugging Common Multi-Step Agent Issues

When your multi-step workflow does not behave as expected, the [SDK’s debugging guide](https://openai.github.io/openai-agents-python/tracing/) recommends starting with trace inspection. The most common failure modes fall into three categories:

#### Handoffs Never Trigger

If your agents never hand off, check the handoff condition string. The SDK interprets it as natural language guidance, so vague conditions like “when done” may not trigger reliably. Make the condition specific: “After completing research summary” or “After reporting analysis results.”

Also check the agent’s instructions. If the instructions never mention handing off, the model may not realize it should. Add an explicit handoff cue: “After completing your task, hand off to the next agent.”

#### Agents Loop Forever

If an agent calls the same tool repeatedly, the tool is probably returning an error or an unexpected result. Check the trace spans to see what the tool returned. If the tool returns `null` or an empty dict, the agent may retry endlessly waiting for a valid result.

Add error handling to your tool and update the agent’s instructions to stop after one failed attempt.

#### Tool Calls Fail Silently

If a tool fails and the agent continues without acknowledgment, the tool is probably raising an exception the SDK is not capturing. Wrap your tool logic in a try-except block and return a structured error dict instead of raising:

```python
@tool
def analyze_research(research_text: str) -> dict:
    try:
        if not research_text or not research_text.strip():
            return {"error": "Research text cannot be empty"}
        
        words = research_text.split()
        sentences = research_text.split('.')
        
        return {
            "word_count": len(words),
            "sentence_count": len(sentences),
            "avg_words_per_sentence": round(len(words) / max(len(sentences), 1), 2)
        }
    except Exception as e:
        return {"error": str(e)}
```

The agent sees the error dict and can adjust its next move instead of proceeding as if the tool succeeded.

### Optimizing Token Usage Across Agents

Each agent in a multi-step workflow consumes tokens per the [SDK’s cost optimization guide](https://openai.github.io/openai-agents-python/). The research agent uses tokens to generate its summary. The analysis agent uses tokens to call tools and reason about the results. The formatter agent uses tokens to produce the final output. When you chain three agents, you’re running three separate model invocations, each with its own prompt and completion.

The SDK includes each agent’s conversation history in its context window. If the research agent produces a 500-word summary, the analysis agent receives that summary plus the original user message. If the analysis agent produces a 300-word tool result, the formatter agent receives the research summary, the tool result, and the original user message. Context grows at each handoff.

You can reduce token usage by keeping agent outputs concise. Update the research agent’s instructions to limit output length:

```python
research_agent = Agent(
    name="ResearchAgent",
    instructions=(
        "You are a research specialist. When given a topic, provide a concise "
        "summary of key facts in 3-5 bullet points. Keep each bullet under 30 words. "
        "After completing your research, hand off to the AnalysisAgent."
    ),
    model="gpt-4.5-turbo",
    handoffs=[
        handoff(
            agent=analysis_agent,
            condition="After completing research summary"
        )
    ],
)
```

Shorter outputs mean smaller context windows for downstream agents, which reduces token usage and improves response time.

You can also use cheaper models for simple agents. If the formatter agent only rearranges text and does not reason, switch it to `gpt-3.5-turbo`:

```python
formatter_agent = Agent(
    name="FormatterAgent",
    instructions=(
        "You are a formatting specialist. Take the analysis results and format "
        "them into a clear, professional summary."
    ),
    model="gpt-3.5-turbo",
)
```

The research and analysis agents still run on GPT-4.5 Turbo for quality, but the formatting step runs on a cheaper model.

## Next Steps

You built a three-agent workflow that chains research, tool calling, and formatting. The SDK handled the handoffs, the tool execution, and the tracing. You wrote the agent instructions and defined the tools.

From here, you can:

*   Add more tools to the analysis agent (sentiment analysis, entity extraction, duplicate detection)
    
*   Wire in real APIs instead of the simulated `analyze_research` function
    
*   Add error recovery agents that catch failures and retry with adjusted parameters
    
*   Integrate the SDK’s [MCP support](https://www.centron.de/en/tutorials/model-context-protocol-mcp-with-openai-agents-sdk-complete-guide) to connect agents to external data sources without writing custom tool functions
    
*   Use the SDK’s [sandbox agents](https://openai.github.io/openai-agents-python/release/) to run untrusted code in isolated containers
    
*   Deploy your multi-step workflow with [Temporal integration](https://temporal.io/code-exchange/openai-agents-python-sdk-demos) for durable execution and human-in-the-loop approval gates
    

Multi-step agent workflows scale by splitting responsibility. When every agent has one job, you can debug, test, and iterate on each agent independently. When a step needs rework, you change one agent. When a new step enters the workflow, you add one agent. The handoff pattern keeps the pipeline clean.

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fopenai-agents-sdk-multi-step-workflows%2F&text=OpenAI%20Agents%20SDK%3A%20Automate%20Multi-Step%20Agent%20Workflows)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fopenai-agents-sdk-multi-step-workflows%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fopenai-agents-sdk-multi-step-workflows%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/publisher/4165d9c85b2b816db4e7cf3aba91f765/240388c80ed62bdb9723757dee9abad2771d764e952d0b7a30a2d01f1d036000.png)

### [Dead-Letter Queue: Stop Failed Agent Tasks from Looping](/dead-letter-queue-agent-tasks/)

Send failed agent tasks to a dead-letter queue, cap retries with backoff, and replay or escalate each one before a poison pill crashes your workers.

![](https://adamtheautomator.com/wp-content/uploads/publisher/4065d9c85b2b814f9e26db58285a5c6d/2fe9e6fcd3f137f3e25263ae52f2ee818bb97d59b094ce182fdb414b1031ff1f.jpg)

### [Build a Production-Ready Helpdesk Triage Agent with Mastra](/build-helpdesk-triage-agent-with-mastra/)

Build a TypeScript helpdesk triage agent with Mastra: a Zod-schema classifier proposes a category, then code routes each ticket to a queue and SLA.

![](https://adamtheautomator.com/wp-content/uploads/publisher/4065d9c85b2b812bba2df8cb767fbe34/9ae655c39d56002e696384ad1bf2fb8f518c75940da65a91ac2668477e001dd3.webp)

### [PowerShell MCP Server: Automate Windows Admin Tasks](/powershell-mcp-server-automate-windows-admin-tasks/)

Build a PowerShell MCP server with PSMCP, register it in Claude Desktop, and expose four read-only Windows tools the model can call safely.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
