Overview
In our previous Agent Skills Guide, we explored how to give a single AI agent access to Sectors Financial API tools. But what happens when a task is too complex for a single agent to handle reliably? In this recipe, we will build a Multi-Agent Workflow using the OpenAI Agents SDK and the Sectors API. We’ll design a robust IDX research assistant using two powerful agentic patterns:- Sequential Chain: Passing the output of one specialized agent (a screener) to another (a researcher).
- Judge and Critic: Using a third agent (an evaluator) to rigorously grade the output and demand revisions if it falls short.
Prerequisites
This recipe assumes you are familiar with generating an API key and completing a basic request. If you haven’t already, review these two recipes: You will need theopenai-agents package for this recipe:
Step 1: Define the Tools
First, we will wrap two Sectors API endpoints into Python tools: a flexible stock screener and a company overview retrieval tool.Step 2: Create the Agents
Instead of using one massive prompt, we create three distinct agents with narrow, specialized responsibilities. This vastly reduces hallucinations and improves accuracy.Step 3: Orchestrate the Workflow
Now we bring it all together. We run the Screener to get tickers and pass those to the Researcher. To ensure quality, we use afor loop to let the Evaluator critique the Researcher’s output. If the output fails, the Researcher is prompted to fix it dynamically.
Summary
By separating concerns into highly specialized agents, we built an AI workflow infinitely more reliable than a single generic prompt. The Screener acts as a targeted retrieval mechanism, the Researcher executes complex data fetching against our financial API, and the Evaluator ensures the final JSON structure matches strict application requirements. You can now reliably pipe this JSON output into a data analysis tool likepandas or build an interactive dashboard!