Skip to main content

View Source Code

Check out the full source code for this example on GitHub.
This tutorial demonstrates how to build a Deep Research Agent using Tensorlake and the OpenAI Agents SDK. This application orchestrates multiple agents to plan, search, and write comprehensive research reports on any given topic.

Overview

The Deep Research Agent consists of three specialized agents that work together in a pipeline:
  1. Planner Agent: Breaks down the user’s research topic into specific search queries and steps.
  2. Search Agent: Executes the planned search queries in parallel, retrieving and summarizing relevant information from the web.
  3. Writer Agent: Synthesizes the gathered information into a structured, comprehensive markdown report.
Each agent runs as an isolated, serverless function on Tensorlake, ensuring scalability and fault tolerance.

Prerequisites

  • Python 3.11+
  • Tensorlake Account and CLI installed.
  • OpenAI API Key

Project Structure

Your project should look like this:

Implementation

1. Define Data Models (models.py)

First, we define the data structures that our agents will use to communicate. This ensures type safety and clear interfaces between the agents.

2. Create the Agents (app.py)

In app.py, we define our Tensorlake functions. Each function represents a stage in the pipeline and utilizes an OpenAI agent.

Running Locally

To test your pipeline locally, add this code block to the end of app.py and run it with python.
Then run the script:

Deploying to Tensorlake

When you’re ready to deploy, use the tl app deploy command.
Your deep research agent is now live and scalable! You can invoke it via the provided HTTP endpoint or the Tensorlake SDK.