Voiced by Amazon Polly |
Introduction
LLMs make natural language interactions possible, but tasks, such as scheduling a doctor’s appointment, entail sophisticated workflows and coordination among systems. LLM agents carry out such tasks but are ineffective in tool proficiency, context handling, and specialization.
A multi-agent architecture utilizes specific agents under a supervisor’s control to achieve the highest scalability and efficiency. Such tools as LangGraph and Amazon Bedrock enable developers to write multi-agent systems. AWS now supports cooperative Amazon Bedrock Agents for task delegation and better outcomes in complex processes.
Pioneers in Cloud Consulting & Migration Services
- Reduced infrastructural costs
- Accelerated application deployment
Challenges with multi-agent systems
Single-agent systems decompose tasks into steps, while multi-agent systems require task allocation and coordination. This creates problems like synchronization, dependencies, and resource sharing, requiring robust frameworks.
Memory in multi-agent systems is intricate, requiring synchronization of context and shared access, as opposed to the short-term and long-term memory of single-agent systems.
Agent frameworks simplify workflow and coordination. LangGraph, developed by LangChain, manages complex workflows with graph-based controls. Amazon Bedrock makes efficient multi-agent LLM applications possible with monitoring and debugging features.
Understanding LangGraph and LangGraph Studio
LangGraph uses state machines and directed graphs to control multi-agent workflows with state and flow precisely. The three workflow components are:
- State: A data structure that shows the app’s current state.
- Nodes: Python functions defining agent logic.
- Edges: Actions that choose the next node according to state, allowing branching or deterministic transitions.
LangGraph has a persistence layer for:
- Memory: Maintains state across sessions, enabling conversational memory and updates.
- Human-in-the-loop: Execution may pause for human input or correction.
LangGraph Studio, a feature-oriented IDE, improves development with:
- Visual agent graphs-based intuitive architecture design.
- Real-time debugging and interactive agent control.
- Stateful, adaptive agents within the graph.
Figure 1: LangGraph Studio UI
Solution overview
This is an example of the supervisor agentic pattern, in which a master Supervisor Agent oversees specialized agents. One scratchpad per agent is dedicated to a particular task, and the supervisor handles communication and delegation, improving efficiency, parallelism, and scalability.
For the query/ user input :
“Suggest a travel destination and search for a flight and hotel. I want to travel on 15-March-2025 for 5 days”. The workflow is:
- Supervisor decomposes the query into tasks.
- Destination Agent examines the user profile to recommend a destination.
- Flight Agent searches for flights on March 15, 2025.
- Hotel Agent retrieves hotels for a 5-day stay.
- Supervisor assembles and returns the full itinerary.
Figure 2: Multi-agent workflow
Core Components of the Worker Agents
Each agent consists of two major constituents:
- graph.py – This script formalizes the agent’s workflow and decision-making strategy. It provides the LangGraph state machine implementation for controlling agent behavior and configures the flow of communication between various components.
- py – This file holds the concrete classes for agent capabilities. It defines the business logic for every operation, as well as data access and manipulation.
Isolating the graph (workflow) from tools (task execution) allows for a clean architecture where decision-making is separated from implementation. With LangGraph’s state-based system, agents exchange information through a structured graph, with the Supervisor Agent controlling task flow and information exchange between specialized agents.
Pre-requisites of the implementation
- A valid AWS account.
- An AWS Identity and Access Management (IAM) role in the account that possesses sufficient permissions to create the resources that are needed.
- Availability of Anthropic’s Claude 3 Sonnet and Claude 3.5 Sonnet on Amazon Bedrock.
- A LangGraph application up and running locally
Steps to set up Amazon Bedrock with LangGraph
- Install the necessary packages:
1 |
pip install boto3 langchain-aws |
These packages are necessary for AWS Bedrock integration:
- boto: AWS SDK for Python, manages AWS service communication
- langchain-aws: Offers LangChain integrations for AWS services
- Import the modules:
1 2 3 |
from langchain_aws import ChatBedrockConverse from langchain_aws import ChatBedrock |
- Create an LLM object:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
bedrock_client = boto3.client("bedrock-runtime”, region_name="<region_name>") llm = ChatBedrockConverse( model="anthropic.claude-3-haiku-20240307-v1:0", temperature=0, max_tokens=None, client=bedrock_client, # other params... ) |
LangGraph studio configuration:
The langgraph.json file defines your app’s structure and dependencies, enabling LangGraph Studio to run, visualize, and debug multi-agent workflows in real-time.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
{ "dependencies": [ "boto3>=1.35.87", "langchain-aws>=0.2.10", "." ], "graphs": { "supervisor": "./src/supervisor_agent/graph.py:graph", "flight": "./src/flight_agent/graph.py:graph", "hotel": "./src/hotel_agent/graph.py:graph" }, "env": "./.env" } |
Testing and debugging
You can now try the multi-agent travel assistant by executing langgraph dev, which begins the LangGraph API server in development mode with hot reloading and debugging. The interface provides a way to choose a graph through the dropdown and set test parameters using the Manage Configuration button, giving a full environment for real-time testing and debugging.
Figure 3: LangGraph studio with Destination Agent recommendation
LangGraph Studio allows you to control multiple versions of configurations (e.g., v1, v2, v3) in an easy-to-use interface to quickly switch configurations, such as using user_id to retrieve past data when testing and debugging your multi-agent system.
Figure 4: Runnable configuration details
In this case, user_id is set to assist tools in fetching user history. The Planner Agent utilizes this to suggest destinations through the compare_and_recommend_destination tool. LangGraph’s checkpoint memory, which is controlled by threads, enables simple tracking and management within LangGraph Studio.
Figure 5: View graph state in the thread
The destination_agent employs a tool whose output can be examined. Likewise, flight_agent and hotel_agent can be tested separately. After all agents function properly, the entire workflow can be tested by checking each agent’s inputs and outputs, as illustrated in the Supervisor Agent’s complete view.
Figure 6: Supervisor Agent with a complete workflow
Considerations
- Multi-agent systems need coordination, state management, and fault handling.
- Graph-based architectures accommodate complex, adaptive workflows and parallelism.
- They require advanced configuration and more computational resources.
- Ensure consistency with AI governance, safety, and data policies.
- Enforce thorough monitoring and fallback procedures for failures.
Clean up
Remove any AWS IAM role and policy set up solely for this implementation. If you no longer want access to an Amazon Bedrock FM, remove access from it.
Conclusion
LangGraph Studio features help in designing and managing intricate agent interactions, with a solid base for next-gen systems that provide reliable results and efficient resource usage.
Drop a query if you have any questions regarding LangGraph or Amazon Bedrock and we will get back to you quickly.
Empowering organizations to become ‘data driven’ enterprises with our Cloud experts.
- Reduced infrastructure costs
- Timely data-driven decisions
About CloudThat
CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.
CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 650k+ professionals in 500+ cloud certifications and completed 300+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training Partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, AWS GenAI Competency Partner, Amazon QuickSight Service Delivery Partner, Amazon EKS Service Delivery Partner, AWS Microsoft Workload Partners, Amazon EC2 Service Delivery Partner, Amazon ECS Service Delivery Partner, AWS Glue Service Delivery Partner, Amazon Redshift Service Delivery Partner, AWS Control Tower Service Delivery Partner, AWS WAF Service Delivery Partner, Amazon CloudFront Service Delivery Partner, Amazon OpenSearch Service Delivery Partner, AWS DMS Service Delivery Partner, AWS Systems Manager Service Delivery Partner, Amazon RDS Service Delivery Partner, AWS CloudFormation Service Delivery Partner and many more.
FAQs
1. How do LangGraph and Amazon Bedrock complement each other to help advance multi-agent systems?
ANS: – LangGraph deals with workflows, while Amazon Bedrock offers scalable, high-performance AI task coordination environments.
2. What are the most important challenges in constructing multi-agent systems, and how does LangGraph overcome them?
ANS: – LangGraph overcomes synchronization, context, and sharing resources via state machines and memory management.
WRITTEN BY Daniya Muzammil
Daniya Muzammil works as a Research Intern at CloudThat and is passionate about learning new and emerging technologies.
Comments