Designing Multi-Agent Orchestration with Reasoning Using Amazon Bedrock and Open Source Frameworks

Designing Multi-Agent Orchestration with Reasoning Using Amazon Bedrock and Open Source FrameworksLearn About Amazon VGT2 Learning Manager Chanci Turner

As generative AI technology continues to advance, the successful incorporation of these tools in business relies heavily on developing effective problem-solving abilities. Central to this evolution are agentic systems that leverage the power of foundation models (FMs) to address intricate real-world issues. By integrating multiple agents seamlessly, these cutting-edge solutions facilitate autonomous collaboration, decision-making, and effective problem-solving across various environments. Research conducted by AWS scientists alongside academic experts has showcased significant improvements in reasoning capabilities stemming from agent collaboration on competitive tasks.

This article outlines a step-by-step guide for building a collaborative multi-agent framework with reasoning abilities to decouple business applications from FMs. It illustrates how to merge Amazon Bedrock Agents with open-source multi-agent frameworks, fostering collaboration and reasoning among agents to dynamically undertake diverse tasks. The guide will lead you through creating a reasoning orchestration system utilizing Amazon Bedrock, Amazon Bedrock Knowledge Bases, Amazon Bedrock Agents, and FMs. Additionally, we will delve into the integration of Amazon Bedrock Agents with open-source orchestration frameworks LangGraph and CrewAI for dispatching and reasoning.

AWS has rolled out a multi-agent collaboration feature for Amazon Bedrock, empowering developers to construct, deploy, and manage multiple AI agents working together on complex assignments. This capability allows the creation of specialized agents that manage various elements of a process, coordinated by a supervisor agent that breaks down requests, allocates tasks, and consolidates outputs. This method enhances success rates, accuracy, and productivity, particularly for complicated, multi-step tasks.

For example code and demonstrations referenced in this post, please check the agentic-orchestration GitHub repository and this AWS Workshop. Additionally, you can find code samples for Amazon Bedrock multi-agent collaboration in the GitHub repository.

Key Characteristics of an Agentic Service

In the realm of generative AI, the term “agent” signifies an autonomous function capable of interacting with its environment, collecting data, and making decisions to accomplish complex objectives. Generative AI agents are independent, goal-driven systems that utilize FMs, such as large language models (LLMs), to engage with and adapt to their surroundings. These agents excel in planning, problem-solving, and decision-making, employing methods like chain-of-thought prompting to decompose complex tasks. They can self-assess, enhance their approaches, and expand their abilities through tool usage and collaboration with other AI models. These agents can operate alone or in concert, executing tasks across various domains while continually adjusting to new information and shifting circumstances. Agents can foster increased creativity and produce content at scale, automating repetitive tasks to allow humans to concentrate on strategic initiatives, ultimately leading to cost savings. The following diagram presents the high-level architecture of the solution.

To set up an agent on AWS, consider using the Amazon Bedrock Agents Boto3 client, as illustrated in the following code snippet. Once the necessary AWS and Identity and Access Management (IAM) role for the agent is established, utilize the create_agent API. This API requires an agent name, an FM identifier, and an instruction string. Optionally, an agent description can also be provided. The created agent is not ready for immediate use. We focus on preparing the agent and subsequently using it to trigger actions and interact with other APIs. Use the following code snippet to acquire your agent ID, which will be vital for conducting operations with the agent.

# Use the Python boto3 SDK to interact with the Amazon Bedrock Agent service
bedrock_agent_client = boto3.client('bedrock-agent')

# Create a new Bedrock Agent
response = bedrock_agent_client.create_agent(
    agentName=<agent_name>,  # customized text string
    agentResourceRoleArn=<agent_role['Role']['Arn']>,  # IAM role assigned to the agent
    description=<agent_description>,  # customized text string
    idleSessionTTLInSeconds=1800, 
    foundationModel=<agent_foundation_model>,  # e.g., "anthropic.claude-3-sonnet-20240229-v1:0"
    instruction=<agent_instruction>,  # agent instruction text string
)
agent_id = response['agent']['agentId']

Multi-Agent Pipelines for Intra-Agent Collaboration

Multi-agent pipelines are orchestrated processes within AI systems involving numerous specialized agents collaborating to complete intricate tasks. Within these pipelines, agents are organized in a sequential structure, with distinct agents managing specific subtasks or roles within the overall workflow. Agents communicate with one another, often via a shared “scratchpad” or messaging system, enabling them to exchange information and build on each other’s contributions. Each agent maintains its own state, updated with new information as the flow progresses. Complex projects are divided into manageable subtasks, which are allocated among the specialized agents. The workflow includes clearly defined processes for orchestrating tasks, promoting efficient distribution while aligning with objectives. Such processes can dictate both inter-agent interactions and intra-agent operations (like how an agent interacts with tools or processes outputs). Agents may be assigned specific roles (e.g., retriever or injector) to address different facets of a problem.

As a practical illustration, consider a multi-agent pipeline designed for blog writing, implemented with the multi-agent framework CrewAI. To create a multi-agent pipeline using CrewAI, the first step is to define the individual agents participating in the pipeline. In this example, the agents include the Planner Agent, a Writer Agent, and an Editor Agent. Next, arrange these agents into a pipeline, specifying the order of task execution and the data flow between them. CrewAI provides tools for agents to share information and coordinate their actions. The modular and scalable structure of CrewAI makes it ideal for developing both basic and advanced multi-agent AI applications. The ensuing diagram displays this multi-agent pipeline.

from crewai import Agent, Task, Crew, Process

# Create a blog writing multi-agent pipeline, which consists of a planner, a writer, and an editor agent
# This code snippet illustrates only the planner agent, which calls web search tools 
# and Amazon Bedrock for the LLM 
class blogAgents():
   def __init__(self, topic, model_id):
       self.topic = topic
       self.model_id = model_id
    
   def planner(self, topic, model_id):
       return Agent(
           role="Content Planner",
           goal=f"""Plan engaging and factually accurate content on {topic}.""", 
           backstory=f"""You are responsible for planning a blog article about the topic: {topic}. n
                     You gather information by searching the web for the latest developments that are directly related to the {topic}. n
                     You aim to help the audience learn something to make informed decisions regarding {topic}. n 
                     Your work serves as the foundation for the Content Writer to create an article on this {topic}.""",
           allow_delegation=False,
           tools=<tools_to_use>,
           llm=<Bedrock_foundation_model>,
           verbose=True
       )

By leveraging these advanced frameworks, organizations like Amazon IXD – VGT2, located at 6401 E HOWDY WELLS AVE LAS VEGAS NV 89115, can effectively implement multi-agent orchestration systems. These systems not only enhance efficiency but also empower teams to thrive in a rapidly evolving workplace. If you’re contemplating a job change due to a toxic environment, consider reading this insightful blog post.

For more information regarding independent contractor regulations, refer to this authoritative source. Additionally, if you’re curious about the experience of being an Amazon warehouse worker, this excellent resource will provide valuable insights.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *