Hands-On Guide to Implementing Multi-Agent Workflows Using LlamaIndex

In this hands-on guide, explore how to build a modular, intelligent multi-agent workflow using LlamaIndex. By combining OpenAI-powered agents with real-time tools and structured memory, you'll learn to create collaborative systems that can research, write, and review complex tasks, unlocking the full potential of GenAI beyond single-prompt interactions.

In the era of GenAI, Large Language Models (LLMs) are evolving from single-task assistants to collaborative agents capable of complex, multi-step reasoning. This guide provides a hands-on walkthrough for implementing multi-agent workflows using LlamaIndex, a robust framework that simplifies coordination between specialized LLM agents. This article demonstrates building agents that can research, write, and review content. Each agent has a focused role, shared memory, and seamless handoff. It enables well-structured and modular AI systems, far beyond a single prompt.

Table of Contents

  1. Understanding multi-agent workflow
  2. Why use a multi-agent system instead of one LLM call?
  3. Overview of LlamaIndex and Its Capabilities
  4. Step-by-step guide: Building a multi-agent system

Understanding multi-agent workflow

Multi-agent workflows originate from the broader field of multi-agent systems in artificial intelligence, where autonomous agents collaborate to solve problems too complex for a single entity. Traditionally used in robotics, simulations, and distributed systems, this concept has recently evolved with the rise of large language models (LLMs). Instead of one model handling everything, modern multi-agent workflows use a team of specialized LLM-based agents. These agents communicate, share memory, and coordinate through a structured workflow.

Why use a multi-agent system instead of one LLM call?

A genuine concern over the workflow can be regarding its effectiveness given that the same task can be performed with a single prompt to any of the available LLMs. Though it might appear to be a logical idea, in reality, a multi-agent workflow offers a structured, modular approach that can significantly outperform a single LLM query, especially for complex tasks like writing a detailed report.

Comparing single llm prompt with multi-agent workflow

Overview of LlamaIndex and its capabilities

LlamaIndex is a powerful framework that helps to connect language models (like GPT) with external data such as documents, databases, APIs, and even real-time tools.

Exploring the key capabilities of llamaindex

Steps to building a multi-agent system

Step 1. Installing the necessary libraries

Ensuring that all core modules and integrations are available for the agents to function effectively.

Step 2. Setting up the OpenAI LLM

Initializing a language model instance using the “gpt-4o-mini” model using the llamaindex framework.

Step 3. Initialize a web-search tool with Tavily

Integrating web search capability into the agent system using the Tavily tool. 

Step 4. Recording research notes into the agent’s memory

Defining an asynchronous function that enables agents to store research findings or observations during the workflow.

Step 5. Writing the final report to agent memory

Defining another asynchronous function that allows the agent to store the final version of a report within the shared workflow memory.

Step 6. Submitting a review of the report

Defining another asynchronous function called that allows the agent to submit feedback or a review for a previously written report. 

Step 7. Initializing the research-agent

Defining a Research Agent, designed to search the web for information on a given topic and take notes.

Step 8. Initializing the write-agent

Defining the Write Agent for drafting a report based on previously gathered research.

Step 9. Initializing the review agent

Defining the Review Agent for reviewing reports generated by the WriteAgent. 

Step 10. Creating the multi-agent workflow

Creating the multi-agent workflow, which defines how the different agents e.g. research_agent, write_agent, and review_agent will work together to complete the task. 

Step 11. Running the workflow with a user prompt

Asking the AI system to create a report on the worldwide stock market crash on 7th April 2025, including a brief explanation of the causes, recovery prospects, and a dedicated section focused on the Indian context.

Step 12. Streaming the output 

Providing visibility into how each agent operates step by step.

The output is as follows:

=========================

Agent: ResearchAgent

=========================

Planning to use tools: [‘search’]

Calling Tool: search

With arguments: {‘query’: ‘worldwide stock market crash April 7 2025 reasons recovery prospects’, ‘max_results’: 6}

Tool Result (search):

Arguments: {‘query’: ‘worldwide stock market crash April 7 2025 reasons recovery prospects’, ‘max_results’: 6}

Output: [Document(id_=’cb559958-0985-4729-a2dc-6f9e7cfd0fbc’, embedding=None, metadata={‘url’:

https://www.cnbc.com/2025/04/06/stock-market-today-live-updates.html‘},

excluded_embed_metadata_keys=[], excluded_llm_metadata_keys=[], relationships={},

metadata_template='{key}: {value}’, metadata_separator=’\n’,

text_resource=MediaResource(embeddings=None, data=None, text=”Beyond that, however, Lefkowitz

expects that structural growth themes like artificial intelligence will

support market recovery in the long term, saying that the S&P 500 can reach 5,800 by the end of

2025. That reflects more than 14% upside from Friday’s closing level.\n\n— Sean Conlon\n\n 

…………

Output: Agent WriteAgent is now handling the request due to the following reason: I have gathered all

necessary information regarding the worldwide stock market crash on April 7, 2025, and its impact on

the Indian market.. Please continue with the current request.

=========================

Agent: WriteAgent

=========================

Planning to use tools: [‘write_report’]

Calling Tool: write_report

With arguments: {‘report_content’: “# Worldwide Stock Market Crash on April 7, 2025\n\nOn April 7, 2025, a historic

stock market crash occurred globally, wiping out over **$10 trillion** from major markets. This

crash was primarily attributed to **uncertainty surrounding new tariff policies** from the Trump

administration and growing economic concerns. 

………

Tool Result (handoff):

Arguments: {‘to_agent’: ‘ReviewAgent’, ‘reason’: ‘The report on the worldwide stock market crash on April 7,

2025, and its impact on the Indian market is ready for review.’}

Output: Agent ReviewAgent is now handling the request due to the following reason: The report on the

worldwide stock market crash on April 7, 2025, and its impact on the Indian market is ready for

review.. Please continue with the current request.

=========================

Agent: ReviewAgent

=========================

Planning to use tools: [‘review_report’]

Calling Tool: review_report

With arguments: {‘review’: ‘The report on the worldwide stock market crash on April 7, 2025, is well-structured and

provides a comprehensive overview of the reasons behind the crash and its recovery prospects.

………

Output: The report on the worldwide stock market crash on April 7, 2025, has been successfully reviewed and

approved. It provides a comprehensive overview of the reasons behind the crash, recovery prospects,

and the impact on the Indian stock market. If you need any further assistance or additional reports,

feel free to ask!

Final Words

This hands-on guide demonstrated how to build a multi-agent workflow using LlamaIndex, integrating OpenAI-powered agents that collaborate to perform complex tasks in a modular, efficient way. By dividing responsibilities between ResearchAgent, WriteAgent, and ReviewAgent, we created a system that mirrors human-like teamwork—capable of real-time web search, structured writing, and iterative refinement. This approach enhances reliability, relevance, and clarity.

Explore some other possibilities with multi-agent systems using llamaindex

References:

  1. Colab Notebook
  2. LlamaIndex Documentation 

Picture of Abhishek Kumar

Abhishek Kumar

Abhishek is an AI and analytics professional with deep expertise in machine learning and data science. With a background in EdTech, he transitioned from Physics education to AI, self-learning Python and ML. As Manager cum Assistant Professor at Miles Education and Manager - AI Research at AIM, he focuses on AI applications, data science, and analytics, driving innovation in education and technology.

The Chartered Data Scientist Designation

Achieve the highest distinction in the data science profession.

Elevate Your Team's AI Skills with our Proven Training Programs

Strengthen Critical AI Skills with Trusted Generative AI Training by Association of Data Scientists.

Our Accreditations

Get global recognition for AI skills

Chartered Data Scientist (CDS™)

The highest distinction in the data science profession. Not just earn a charter, but use it as a designation.

Certified Data Scientist - Associate Level

Global recognition of data science skills at the beginner level.

Certified Generative AI Engineer

An upskilling-linked certification initiative designed to recognize talent in generative AI and large language models

Join thousands of members and receive all benefits.

Become Our Member

We offer both Individual & Institutional Membership.