AWS Logo
Menu
Multi-Agent Collaboration Using Cost Effective RAG

Multi-Agent Collaboration Using Cost Effective RAG

Build an AI travel concierge with Amazon Bedrock and OpenSearch vector store. Learn to create specialized AI agents for travel planning and hotel booking

Published Feb 4, 2025
In this post, we will explore Amazon Bedrock's new feature for multi-agent collaboration, enabling agents to specialize and collaborate on tasks.
Basic terms and Tools (Optional)
Agent: An agent is an autonomous entity, typically a program, that helps automate problem-solving processes or assists users in achieving their goals. It uses user input to determine the best possible steps or paths to reach the desired outcome in a given situation or under specific conditions.
Foundation Model: A model capable of performing a wide range of tasks across multiple domains. These models leverage their training on diverse domains and datasets to be used off-the-shelf usually for tasks across multi domain. They can be fine-tuned for specific tasks with minimal additional training.
Semantic Search: A type of search that understands the semantic meaning of words or the context in which they appear. To incorporate semantic search into projects, a vector database is required. We will be using OpenSearch Vector Database.
Embedding: The transformation of data, usually text data, into numeric vectors. This allows the data to be compared against a datastore using similar embeddings for semantic search, rather than relying on lexical or keyword search.
Knowledge Base: A datastore for personalized, usually business proprietary data, which the LLM (Large Language Model) is typically not aware of. It is used to implement RAG (Retrieval Augmented Generation), where the LLM searches its knowledge base for answers before querying the LLM itself. We use a Vector Database for semantic search.

Tools

Bedrock: A fully managed service for building generative AI applications that interact with Amazon models and other third-party foundation models.
OpenSearch Serverless (Vector Store): An AWS managed service for storing indexed data with shards. It enables the creation of a scalable Vector Store for semantic search without worrying about the details or configuration.
S3 (Data Source): We store our initial data documents in S3 before converting them to vector embeddings.
Lambda (Optional): A serverless compute service used to create action groups.

Overview

In this guide, we will demonstrate how to build a travel concierge (travel attendant) agent that guides users on travel itineraries and hotel booking based on their budget and preferences.
We start by requesting access to our foundation models to generating synthetic data for our Knowledgebase, which we will store in S3 as our data source. We will embed the original data in S3 using a Bedrock Embedding Model as vectors and store them in the OpenSearch database. We will mostly use Amazon Titan models for a more cost effective solution.
Architecture Diagram
Architecture Diagram of our Multi-Agenti Collaboration Travel System
Architecture Diagram of our Multi-Agenti Collaboration

Implementation

Prerequisite
Request access to the following Bedrock models: Amazon Titan Prime, Titan Embedding v2, and Nova Micro.
Requesting Foundation Models Access (Optional)
Before starting, you may need access to specific Amazon Bedrock foundation models. Navigate to the Bedrock console and select "Model Catalog" from the left navigation pane. Under Filters, select "Amazon" to view Amazon-specific models. For your desired model, click the three-dot menu icon and select Modify Model Access from the dropdown. Under BaseModel click Available to request on a model you want and click Request access on the pop up as shown on BaseModel tab, then as shown on Edit Model tab below select these models: Titan Embedding v2 (for vector embeddings), Titan Text G1 - Primer, and Nova Micro. Click "Next" to review your selections and "Submit" to complete the request.
visual of depicting requesting model access through the model catalog
Bedrock Model Request
Content for tab 1
 

Generating Synthetic Data for Our Data Source

  1. Navigate to Playground: In the Bedrock console, select "Chats" under the "Playground" section.
  2. Select Model: Click "Select model." In the pop-up, choose "Amazon" under Categories, then select "Titan Text G1 - Premier" from the Models list, and click "Apply."
  3. Generate Text: Provide prompts to the model to generate text for your knowledge base. For example, you can create instructions for hotel booking and travel advisor agents. Save the generated text to a text file.
  4. Upload to S3: Upload the text file to your S3 bucket as your data source. Create a bucket for your knowledge base and organize your files into folders, such as "travel" and "hotel."
Navigating to chats section of Play ground
Chat Play ground
Content for tab 1
 

Example Instructions for Agents

Hotel Booking Agent Instructions:
You will act as an expert on hotel bookings. You will generate a step-by-step guide on how to book a hotel room. You know the following fictional hotel chains: LuxStay, ComfortInn, and BudgetLodge. For each of these chains, provide a general description and their features. Next, provide a numbered list describing how to book a room at each hotel chain. Include information about how to ensure the best rates and availability. Answer only with the instructions and hotel descriptions. Avoid answering with affirmations like: "OK, I can generate it," or "As an expert on hotel bookings, I ". Be direct and only reply with the instructions and descriptions.
Travel Advicer Instructions
You will act as an expert travel advisor. You will generate a step-by-step guide on how to plan a travel itinerary. You know the following fictional travel destinations: SunnyBeach, MountainEscape, and CityAdventure. For each of these destinations, provide a general description and their main attractions. Next, provide a numbered list describing how to plan a trip to each destination. Include information about how to ensure a safe and enjoyable trip. Answer only with the instructions and destination descriptions. Avoid answering with affirmations like: "OK, I can generate it," or "As an expert travel advisor, I ". Be direct and only reply with the instructions and descriptions.
Creating Knowledge Base
After generating text files and storing your data in our S3 data.
On the Bedrock left menu select Knowledgebase, and click create and select create with vector store , depicted on the "Create KB" tab below
on the Knowledge Base details page give the knowledgebase a user friendly name and ensure to leave "Create new user service role" under IAM policy unchanged, select Next to proceed to the next page,
on the Data source details page chose Amazon S3 as your data source and click Next ,
on the Configure data source page, click "Browse S3" and select your s3 bucket location where the travel documents are stored click Next,
on the Select Embedding page select Titan Text Embeddings v2 as the Embeddings model and under Additional configurations select Binary vector embeddings to save cost click, leave "Quick create a new vector store" unchanged, click Next
review the knowledge base and click Create Knowledge Base .
If you must really save cost you can head over o OpenSearch serverless and delete the Knowledgebase collections to save cost, this will affect the sub agents.
Selecting Vector Knowledgebase as type to create
Creating Vector KnowledgeBase

 

Creating Agents

On the Bedrock left menu select Agents, on the Agents page click Create agent , on the pop up give your agent a user friendly name like TraveAdvicer , ensure not to enable multi-agent collaboration while naming the agents (as shown on the tabs below), that is meant for the Supervisor agent, create another agent you can name it HotelBooker . The Agents will not yet be in the prepared state.
On the Agents page select your Agent ("TravelAdvicer" or "HotelBooker") then click Edit
on the Agents builder page Ensure to leave Create new Service role unchanged, then copy and paste instructions for your agent and click save.
under Knowledge Bases on the Agent Builders page click add to add your knowledge base, select your previously created knowledgebase. Ensure you have saved your agent before adding a knowledge base. After adding the Knowledge base click Save and exit on the Agent builders page, click Prepare and then Test to test your agent.
Starting Agent creating process
Select Create

 
After creating the agent, create an Alias of it, so we can add to our supervisor agent for collaboration
click the specific agent and clicking `create Alias` on that agent page
Creating Alias
Content for tab 1
 
Follow the same steps to create a "HotelBooker" or other agent
Creating Supervisor Agent
On the Agents page click create, give the supervisor agent any name like "TravelSupervisor", Ensure to enable multi-agent collaboration and click create
Editing the Supervisor agent on Agent builder, select Amazon nova micro as the language model and paste instructions for your supervisor agent (see our instruction below), click save to save the agent before proceeding to add collaborators (sub agents).
Scroll down and under multi-agent collaboration click Edit you can add your previously created agents ("TravelAdvicer", "HotelBooker")
On the Multi-agent collaboration page under Agent collaborator select your agent, we selected our TravelAdvicer and select the agent Alias, give your agent an alternate collaborator name , Write or paste instructions for your collaborator agent, see our TravelAdvicer instruction below as a collaborator agent
Naming Supervisor Agent and enabling multi agent collaboration
Supervisor Agent
Content for tab 1
 
our Supervisor Agent instruction
You are a Travel Concierge Supervisor who oversees the operations of the travel booking and advisory agents. Your capabilities include: 1. Monitoring the performance of booking and advisory agents 2. Providing guidance and support to agents 3. Ensuring seamless coordination between agents 4. Handling escalations and complex issues 5. Creating reports on agent performance and user satisfaction. Core behaviors: 1. Always use available information before asking agents for additional details 2. Maintain a professional yet approachable tone 3. Provide clear, direct answers and guidance 4. Present information in an easy-to-understand manner. Escalation protocol: - Only handle escalations that agents cannot resolve - Respond exclusively with case ID when creating tickets for further assistance - Decline providing specialist advice beyond your scope. Response style: - Be helpful and solution-oriented - Use clear, practical language - Focus on actionable guidance - Maintain natural conversation flow - Be concise yet informative - Do not add extra information not required by the agents
Paste this instruction or craft similar one for your Collaborator agent (TravelAdvicer);
You can invoke this agent for travel planning tasks such as creating personalized travel itineraries and providing travel recommendations. The agent offers tailored advice based on user preferences and ensures a safe and enjoyable trip. The agent's capabilities include: 1. Providing travel itinerary planning instructions 2. Offering travel recommendations based on user preferences 3. Troubleshooting common travel planning issues 4. Creating support tickets for specialist assistance. Core behaviors: 1. Always use available information before asking customers for additional details 2. Maintain a professional yet approachable tone 3. Provide clear, direct answers 4. Present travel information in an easy-to-understand manner. Support ticket protocol: - Only generate tickets for specialist-level issues - Respond exclusively with case ID when creating tickets - Decline providing specialist advice beyond your scope. Response style: - Be helpful and solution-oriented - Use clear, practical language - Focus on actionable guidance - Maintain natural conversation flow - Be concise yet informative - Do not add extra information not required by the user
You can similarly add other collaborators like HotelBooker click Save
Naming Supervisor Agent and enabling multi agent collaboration
Supervisor Agent
Content for tab 1
 
After adding your collaborator agents click save to save your Agent. You can click prepare to get your agent ready for testing

Conclusion

We have successfully created and test multi agent collaboration capability in Amazon Bedrock. Future improvements could include adding agents containing Action groups , creating the Multi-Agent collaboration app programmatically using tools like SageMaker notebook.

References

Comments