Skip to main content
This example project is derived from the brilliant deep research guide by Nico Albanese.

Overview

This full-stack Next.js project is an intelligent deep research agent that autonomously conducts multi-layered web research, generates a comprehensive structured report, converts it to a PDF, and uploads it to cloud storage — all with real-time progress updates on the frontend. Tech stack:

GitHub repo

View the deep research agent repo

Fork this repo to use it as a starting point for your own research agent.

How the agent works

Task orchestration

Three Trigger.dev tasks are chained together using triggerAndWait, each handling a distinct phase of the pipeline:
  1. deepResearchOrchestrator — coordinates the entire research workflow
  2. generateReport — converts accumulated research into a structured HTML report using GPT-4o
  3. generatePdfAndUpload — converts the HTML to PDF with LibreOffice and uploads to R2
src/trigger/deepResearch.ts

Recursive research algorithm

The core research logic uses a recursive depth-first approach. At each level the agent:
  1. Generates multiple search queries from the current question using GPT-4o
  2. Searches the web via the Exa API
  3. Evaluates the relevance of each result
  4. Extracts key learnings and follow-up questions
  5. Recurses on the follow-up questions at the next depth level

Real-time progress with Trigger.dev Realtime

The frontend uses the useRealtimeTaskTrigger hook to both trigger the task and subscribe to progress updates without polling:
src/components/DeepResearchAgent.tsx
As research progresses, the task updates its metadata and the frontend receives each update automatically:
src/trigger/deepResearch.ts

Relevant code files

Learn more

Trigger.dev Realtime

Subscribe to runs and stream live progress to your frontend

React hooks

Trigger a task and subscribe to its updates from a React component

Run metadata

Store and broadcast arbitrary data from inside a running task

triggerAndWait

Chain tasks together and wait for each to complete before continuing