How to Build an AI Agent System That Automatically Writes Research Reports
A hands-on guide using LlamaIndex, Tavily, and Python
In today’s world of accelerating information flow, AI agents are quietly transforming how research is conducted and reports are produced.
In finance especially where analysts must synthesize massive amounts of real-time news, corporate filings, and market data, which is an automated, structured AI agent system can dramatically improve both productivity and insight quality.
In this article, we’ll walk through how to build a multi-agent research workflow using LlamaIndex and Python. The system automatically searches the web, records notes, drafts structured reports, and performs quality reviews, all without human intervention.
1. System Overview
Our AI research report workflow consists of three collaborating agents, each with distinct responsibilities:
ResearchAgent — Searches the web for information on a given topic and records findings as structured notes.
WriteAgent — Synthesizes the notes into a structured research report in Markdown format.
ReviewAgent — Reviews the report, provides feedback, and either approves or requests revisions.
These agents communicate and coordinate within a workflow orchestrator called AgentWorkflow, ensuring seamless task handoffs and completion.
2. Environment Setup and Dependencies
We’ll build our multi-agent system using the LlamaIndex framework and Tavily for web search. To keep API credentials secure, we’ll use dotenv to load them from a .env file.
import os
from llama_index.llms.openai import OpenAI
from llama_index.core.workflow import Context
from llama_index.core.agent.workflow import (
FunctionAgent,
ReActAgent,
AgentWorkflow,
AgentInput,
AgentOutput,
ToolCall,
ToolCallResult,
AgentStream,
)
from tavily import AsyncTavilyClient
from dotenv import load_dotenv
load_dotenv()
llm = OpenAI(model=”gpt-4o”)

