How to Build a Multi-Agent Research Assistant in Python

Learn to build a multi-agent AI research assistant using the OpenAI Agents SDK, GPT-4o mini, and the Olostep Web API to produce structured, source-grounded repo

How to Build a Multi-Agent Research Assistant in Python

In this article, you will learn how to build a multi-agent AI research assistant using the OpenAI Agents SDK, the GPT-4o mini model, and the Olostep Web API, including how to wire together a manager agent, specialist sub-agents, and live web tools to produce structured, source-grounded research reports.

Topics we will cover include:

  • How to define a manager agent that orchestrates a judge agent and an analyst agent to progressively gather and evaluate evidence.
  • How to integrate Olostep’s Answer, Search, Search-with-Scrape, and Scrape APIs as callable tools inside the OpenAI Agents SDK workflow.
  • How to expose the finished research assistant as an interactive web application built with Reflex, complete with PDF export.

How to Build a Multi-Agent Research Assistant in Python

Introduction

The OpenAI Agents SDK makes it straightforward to build agentic AI applications. What stands out is how simple it is to create a multi-agent workflow: you define a manager agent, connect it with specialist sub-agents and tools, and let it decide how to complete the task.

The manager agent can delegate work to other agents, call tools directly, and coordinate the overall research process. This makes it possible to build AI applications that do more than generate text — they can search the web, gather information, organize findings, and produce grounded outputs.

In this guide, we will build a multi-agent AI research assistant using the OpenAI Agents SDK, the GPT-4o mini model, and the Olostep Web API. The assistant will generate a structured research report that is grounded in web data, easy to read, and produced in just a few seconds.

The guide also includes the full code, a web app, and a link to the deployed version so you can test the system yourself. By the end, you will understand how multiple agents can work together to create a practical research assistant from scratch.

1. Set Up the Environment

Before building the multi-agent research assistant, we need to set up the Python environment and configure the required API keys.

We will use four main packages:

  • openai-agents for building and running the multi-agent workflow
  • olostep for accessing live web data
  • pydantic for defining structured outputs
  • python-dotenv for loading API keys from a .env file

Run the following command to install the required packages:

pip install -q -U openai-agents olostep python-dotenv pydantic

Next, create a .env file in your project directory. This file will store your API keys securely, so you do not need to hardcode them inside your notebook or application.

OPENAI_API_KEY=your_openai_api_key
OLOSTEP_API_KEY=your_olostep_api_key

You can create your OpenAI API key from the OpenAI Platform. Sign in to your OpenAI account, go to the API keys section, and generate a new key for this project. Make sure your OpenAI API account has billing enabled and at least $5 in credits available before running the examples. You may also need to complete account verification to access the latest models.

For Olostep, create a free account from the Olostep website and generate an API key from your dashboard. The free plan includes 500 successful requests with no credit card required, which is enough to test the research assistant in this guide.

Once your keys are ready, we will start in a Jupyter Notebook by importing the required libraries and loading the environment variables. This setup prepares the notebook to work with OpenAI, Olostep, structured outputs, and tracing.

import json
import os
from datetime import datetime
from typing import Any
from dotenv import load_dotenv
from IPython.display import Markdown, display
from olostep import Olostep
from pydantic import BaseModel, Field
from agents import (
    Agent,
    Runner,
    custom_span,
    flush_traces,
    function_tool,
    gen_trace_id,
    trace,
)

load_dotenv()

OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
OLOSTEP_API_KEY = os.getenv("OLOSTEP_API_KEY")

2. Test Olostep Search with Scraping

Before building the full multi-agent workflow, it is useful to test whether Olostep can search the web and scrape the returned pages successfully. This step confirms that your API key is working and that the search results include enough page content for downstream analysis.

The Olostep Search API is especially useful because it can return search results with a built-in scraping option. Instead of only receiving page titles, snippets, and links, you can ask Olostep to scrape the returned URLs and provide the extracted content in formats such as Markdown.

This means the agent can work with high-quality page content directly, rather than relying only on search snippets. It also saves time because you do not need to build a separate search-and-scrape pipeline yourself.

client = Olostep(api_key=OLOSTEP_API_KEY)
search = client.searches.create(
    query="What are the most important recent developments in AI agents for business research?",
    limit=5,
    scrape_options={"formats": ["markdown"], "timeout": 25},
)

for link in search.links:
    print(link["url"], "-", len(link.get("markdown_content") or ""), "chars")

This tells Olostep to scrape each returned page and provide the extracted content in Markdown format. Markdown is useful because it keeps the content readable while removing unnecessary page clutter. The timeout value gives Olostep enough time to fetch and process each page.

After the search is complete, we loop through the returned links and print each URL along with the number of characters extracted from the page.

3. Add Helper Functions

Before creating the agents and tools, we need to add a few helper functions. These utilities keep the rest of the code cleaner and make the workflow easier to debug.

The helper functions will handle six things:

  • Check whether the Olostep API key is available
  • Create a reusable Olostep client
  • Convert SDK responses into standard Python dictionaries
  • Compress large JSON outputs so they are easier to inspect
  • Add the current date and year as context for the agents
  • Normalize search results into a simpler format for the agents

With the environment configured, Olostep validated, and helper utilities in place, you have everything needed to define the agents, wire up the tools, and build the full multi-agent research workflow.