How to Build Custom Deep Research Agents (Better than OpenAI)

Arseny ShatokhinAbout 6 min readJul 9, 2025Watch original
THE SUMMARYAI-generated

Deep Research Agents with Local Data: A Comprehensive Guide

Key Concepts:

  • Deep Research Models (OpenAI): New models focused on in-depth research capabilities.
  • MCP (Model Communication Protocol): A protocol for agents to communicate with external tools and data sources.
  • Context Engineering: Techniques to improve the relevance and accuracy of AI agent responses.
  • Agents SDK: A software development kit for building AI agents.
  • Responses API: OpenAI's API for interacting with deep research models.
  • Clarifying Agent: An agent that asks clarifying questions to refine the user's request.
  • Instruction Builder Agent: An agent that generates detailed instructions for the research agent.
  • Research Agent: The agent that performs the actual research based on the instructions.
  • Vector Stores: Databases that store data in a way that allows for efficient similarity searches.

1. Introduction to Deep Research Agents

The video introduces the creation of custom deep research agents using local data, claiming they are significantly better than OpenAI's default offerings due to customization. The core idea is to leverage context engineering techniques to tailor these agents for specific business needs. The presenter highlights the potential for reselling these agents, even charging per report, which could replace expensive human data analysis.

2. Leveraging New OpenAI Technologies

The agents are powered by OpenAI's new deep research models, which are accessible through the Responses API. The video also emphasizes the importance of OpenAI's web search model, which is cost-effective ($10 per 1K tool calls) and saves significant development time. The new version of the agencies-form framework is used, which is fully based on the Responses API and is an extension of the Agents SDK. This ensures compatibility with current and future Agents SDK features.

3. Repository Overview: Basic vs. Multi-Agent Research

The video references a GitHub repository containing examples:

  • Basic Research Agent: A single agent powered by the offer mini model with a web search tool and a hosted MCP tool.
  • Multi-Agent Research: An agent mirroring OpenAI's deep research approach, comprising three agents:
    • Clarifying Agent: Refines the user's query.
    • Instruction Builder Agent: Creates detailed instructions for the research agent.
    • Research Agent: Executes the research.

4. Setting Up the Environment

The video provides a step-by-step guide to setting up the environment:

  1. Clone the repository.
  2. Create a virtual environment and install the required packages.
  3. Add the OpenAI API key to the environment variables.
  4. Optionally, specify a custom vector store ID. If not provided, the repository will create one automatically.

5. Basic Research Agent in Detail

The basic research agent utilizes a web search tool and a hosted MCP tool. The hosted MCP tool is a significant addition, as it signifies OpenAI's acceptance of MCP as an industry standard. This tool interacts with an MCP server remotely, meaning the server must be hosted on the internet, not locally. OpenAI's deep research models currently only support hosted MCP tools. The MCP server is limited to two tools: a search tool and a fetch tool, with a specific list of parameters. The provided server recreates OpenAI's file search tool, using vector stores to search and fetch files. To use it, users need to add their files to the "files" folder.

Process for running the Basic Research Agent:

  1. Activate the virtual environment.
  2. Run the python mcp/start_mcp_server.py command to start the MCP server.
  3. Expose the server to the internet using Ngrok (ngrok http <port>).
  4. Copy the Ngrok URL and add it to the .env file, including the /sse endpoint.
  5. Run the python basic_research_agent/agent.py command.
  6. Optionally, use the visualize method to view an interactive dashboard of the agent and its tools.

The presenter demonstrates the agent by asking "What is context engineering in AI?" and sets a max_tool_calls parameter to 8 to limit the runtime. The agent performs web searches on GitHub, news sources, and arXiv. The generated report is saved in PDF format in the "reports" directory, including the query, formatted content using markdown, and references.

6. Deep Research Agent (Multi-Agent) in Detail

The deep research agent consists of three agents: a research agent, an instruction builder agent, and a clarifying agent. This setup allows for more comprehensive and detailed prompts. Each agent has its own specific instructions file.

Process for running the Deep Research Agent:

  1. Add max_tool_calls to the research agent.
  2. Run the deep_research_agent/agent.py file.

The presenter asks "What is context engineering in AI?" The clarifying agent asks follow-up questions to understand the user's specific interests (e.g., techniques, building AI agents, technical details vs. high-level explanation). The clarifying agent uses structured outputs to generate these questions. The instruction builder agent then creates a comprehensive prompt based on the answers, which is passed to the research agent. The resulting report includes code snippets, a comparison table of techniques and frameworks, practical use cases, and references.

7. Customizing the Agent for Specific Use Cases

The process for customizing the agent is outlined:

  1. Copy the deep_research_agent folder (or a simpler template) to the root directory and rename it.
  2. Add relevant files to the "files" directory. The presenter adds documentation files for agencies-form, crewAI, langraph, and paidenic AI.
  3. Optionally, copy the mcp folder, rename it, and customize the server.py file to create a custom MCP server. The presenter creates a GitHub MCP server to search and fetch files from the specified frameworks.
  4. Use a coding assistant (e.g., Claude) to customize the MCP server, ensuring the input and output parameters remain the same.
  5. Add the GitHub token if building a similar agent.
  6. Run the start_mcp_server command with the correct port.
  7. Expose the server using Ngrok and add the new URL to the research agent as a hosted MCP tool.
  8. Adjust the instructions in the clarifying agent and instruction builder agent to reflect the specific business overview and research task. The presenter emphasizes the importance of writing detailed instructions, similar to writing an essay. The research agent itself requires minimal instructions.

8. Running the Customized Agent and Analyzing the Results

The presenter runs the customized agent without specifying max_tool_calls. After answering the clarifying questions, the instruction builder agent generates a comprehensive prompt, and the research agent begins the research. After over 20 minutes and 30 tool calls, the research is completed. The resulting 18-page report identifies missing features in agency Swarm (graph abstraction, built-in UI/DSLI), suggests improvements to modularity and testing, and recommends adding a formal workflow layer. It also highlights the framework's lightweight nature and proposes an architecture pattern. The report provides strategic recommendations and integrates memory and concurrency.

9. Potential Applications and Conclusion

The presenter emphasizes the value of the generated report, stating it could easily cost hundreds of dollars to produce with human effort. He suggests that marketing agencies with large amounts of data could greatly benefit from such agents, especially if the MCP allows searching through previous campaigns and customer data. The video concludes by promoting a no-code agent building process using their platform and upcoming features, such as deploying agents directly from GitHub repositories. The presenter encourages viewers to subscribe for future updates.

Notable Quotes:

  • "Customization is key to making AI useful."
  • "This hosted MCP tool actually does not call your MCP server locally. This tool actually calls it remotely. So this means that the request to your MCP server will actually be going from Open AI servers, not from our local machine."
  • "Instructions are actually super important and I suggest writing them like you would write an essay."

AI summaries can miss context or contain errors. Check important details against the original video.

Go a little deeper.

Have a question about this video? Load its transcript to open the video chat.