3 Advanced AI agent design patterns

Google Cloud Tech · Beginner ·🤖 AI Agents & Automation ·3mo ago

Key Takeaways

The video covers advanced AI agent design patterns, including the loop review and critique pattern, coordinator router pattern, and agent as tool pattern, for building dynamic multi-agent systems.

Full Transcript

Hi, welcome back to this agendic pattern series. In last part we cover some use case with agenic pattern from single agent to multi- aent pattern with sequential workflow agents and parallel workflow agents. And in today's video, we will explore advanced patterns with coding example and demo to showcase review and critique with loop agent, hierarchical task decomposition with LM agent and agent as tool. So by the end of today's video, you will learn how to design multi- aent system that gives your agent the ability to iterate, self-correct, and dynamically choose the right tool for the job. All right. So for the first part of today's example is the loop review and critique pattern. When we design an agent system to plan a trip, what if you need the agents output to meet a certain non-negotiable requirement? For example, you need to plan a trip to an event, but the hotel and event venue must be within 30 minutes of travel time. And in this case we can use this loop pattern and often implement it as a review and critique workflow. And here is how it works. So first we have a generator agent that creates a initial trip plan. And then we have a critique agent evaluates that plan against our condition. For example, if this travel time is less than 30 minutes. So if this condition isn't met, the loop sends it back to the generator with feedback for revision. This loop will continue until the plan is approved or we hit a maximum number of iteration to prevent infinite loops. And this is a form of iterative refinement. So here is code implementation to demonstrate this agenic pattern. As you can see, we implement the critique agent with loop agent and then put together the generator agent and critique agent with sequential agent. And now let's test with ADK web UI by type ADK web. We will type our request here. And in the tracing tab, you can see this loop in action. The planner generates a trip and the critique tries the travel time and rejects it. And the planner tries again with a different plan until it meet the condition. And this is really powerful when we need a task to be accurately meeting certain conditions. The advantages of this pattern is that it can ensure output meets specific quality standards and any constraints. It is helpful when we prioritize certain criteria. However, by getting into this many iterations, it increases latency and cost for the whole system and we need to be really careful designing this exit condition which can add complexity to our system. So now we learn this review and critique pattern. The next is very common popular one which is coordinator router pattern. And so far our multi- aent workflow have been predefined with sequential agent, loop agent or parallel agent. You can think of this coordinator agent as a smart project manager. It analyze uses request and then delegates to the correct specialized agent from a team of experts. And let's take a look at this example with hierarchical task decomposition. This is where a coordinator breaks a large task into smaller subtask and delegate those to the other agents. Imagine we have a top level coordinating agent and the job is to plan a full experience and below it we have specialized sub agent. We have a food and transportation agent which is a sequential agent that we built last video and you can check this link to review last video. We also have this nearby places agent which is a parallel agent that we also built in last video. We also have this trip cost agent and you can see in from the code on the screen that we put the agent as sub agent for this coordinate agent where we use LM agent to implement it. Now we can see it in action in ADK web UI. And if I ask the main coordinator, plan a trip to find a sushi in San Francisco and find my way to getting there. This coordinator knows that this requires both food and travel. So it delegates the entire task to this food and transportation sub agent. And that agent then executes its own sequence. First finding the food and then the transport. Now I can continue the conversation. Okay. I also want to find a museum and concert. The main coordinator understands this new request and then delegate it to this nearby places agent and that agent then run its own parallel workflow searching for both at the same time and then summarizing the result. The benefit of this design is that it is extremely flexible and it can solve very complex problem by breaking them down. However, it has higher latency and cost because we use extra model costs for routing and this multi-level structure can be more complex design and troubleshooting. And now let's get to the last part of today's video which is agent as tool pattern. So let's talk about the subtle but very powerful alternative to the coordinator. the agent as a tool pattern. On the surface level, it looks very similar to coordinator. You have a primary agent and several specialized sub agent. But the key difference is in control and state management. In the coordinator pattern, the main agent delegates the task. The sub agent take full control and solve its piece of puzzle. But in the agent as tool pattern, the primary agent treats a sub agent like simple stateless tool. It calls a sub agent to perform a function, gets a result back and the main agent retains full control and manage the overall state. You can think of it like a coordinator is a manager who gives a project to an employee and an agent as a tool is a craftsman who pick up a specific tool and to do one part of the job before picking up the next tool. And you can take a look at how we rewrite this coordinator example in the agent as a tool pattern in the code on the screen. All right, there you have it. We have covered everything from the simple single agent to the dynamic coordinator pattern and each design has its trade-off between control, flexibility, cost and complexity. And here's the summary to compare those pattern. So in summary, you use a single agent for simple prototypes. You use sequential and parallel agent, but you need a reliable and structured workflow. And you can use loop when you want to meet certain criteria and use a coordinator or agent as a tool when you need a dynamic flexible routing to solve complex problems. All right, I hope now you have a much better understanding of how to design and build your own agentic AI system with different design patterns. All right, thank you so much for watching and see you in future [music] videos. Bye. Heat. Heat. N.

Original Description

Agentic Pattern Lab → https://goo.gle/agenticpattern Multi-Agent Pattern Blog → https://goo.gle/multiagentpattern Design Agentic Pattern → https://goo.gle/agenticpatterndesign Learn advanced AI Agent Design Patterns for building dynamic, multi-agent systems! In Part 2 of our agentic AI tutorial, we use the Agent Development Kit (ADK) to build Loop, Coordinator, and Agent-as-Tool workflows. In this AI tutorial, we cover: * The Loop Pattern (Review & Critique): Build self-correcting AI using a Generator and Critic agent to iteratively refine outputs until strict conditions are met. * The Coordinator Pattern (Dynamic Routing): Create a "smart manager" that uses hierarchical task decomposition to dynamically route complex LLM requests to specialized sub-agents. * The Agent as Tool Pattern: Learn the crucial difference between delegating tasks (Coordinator) and treating sub-agents as stateless tools to maintain full system control. Chapters: 0:00 - Intro 1:09 - Pattern 1: The loop pattern (review and critique) 3:08 - Pattern 2: Coordinator (Router) Pattern 3:26 - Hierarchical Task Decomposition with LLM agent 5:33 - Pattern 3: "Agent as tool" pattern 6:49 - Recap More resources: ADK Doc → https://goo.gle/4bmJMdR Foundations of multi-agent systems with ADK → https://goo.gle/4lw3EA7 Workflow agents and communication in ADK → https://goo.gle/4lsAlhD Watch more AI agent crash course→ https://goo.gle/AIforBeginners 🔔 Subscribe to Google Cloud Tech → https://goo.gle/GoogleCloudTech #GoogleCloud #AIAgents #ADK Speakers: Annie Wang Products Mentioned: Agent Development Kit
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Google Cloud Tech · Google Cloud Tech · 0 of 60

← Previous Next →
1 I’m going for it #GoogleCloudCertified
I’m going for it #GoogleCloudCertified
Google Cloud Tech
2 I had to get #GoogleCloudCertified
I had to get #GoogleCloudCertified
Google Cloud Tech
3 Be better overall at what you do #GoogleCloudCertified
Be better overall at what you do #GoogleCloudCertified
Google Cloud Tech
4 Cloud Monitoring on our radar #Analysis #Uptime
Cloud Monitoring on our radar #Analysis #Uptime
Google Cloud Tech
5 Introduction to Generative AI Studio
Introduction to Generative AI Studio
Google Cloud Tech
6 How to use Github Actions with Google's Workload Identity Federation
How to use Github Actions with Google's Workload Identity Federation
Google Cloud Tech
7 Introduction to Responsible AI
Introduction to Responsible AI
Google Cloud Tech
8 Networking updates and CDMC-certified architecture
Networking updates and CDMC-certified architecture
Google Cloud Tech
9 Create and use a Cloud Storage bucket
Create and use a Cloud Storage bucket
Google Cloud Tech
10 How to digitize text from documents
How to digitize text from documents
Google Cloud Tech
11 Faster analytical queries with AlloyDB
Faster analytical queries with AlloyDB
Google Cloud Tech
12 Next ‘23 sessions and FaaS Wave
Next ‘23 sessions and FaaS Wave
Google Cloud Tech
13 Introduction to Assured Open Source Software
Introduction to Assured Open Source Software
Google Cloud Tech
14 BigQuery Cost Optimization: Storage
BigQuery Cost Optimization: Storage
Google Cloud Tech
15 BigQuery Cost Optimization: Compute
BigQuery Cost Optimization: Compute
Google Cloud Tech
16 BigQuery Cost Optimization: Select Queries
BigQuery Cost Optimization: Select Queries
Google Cloud Tech
17 Remote Field Equipment Management with Manufacturing Data Engine
Remote Field Equipment Management with Manufacturing Data Engine
Google Cloud Tech
18 Supercharging your applications with Cloud SQL Enterprise Plus
Supercharging your applications with Cloud SQL Enterprise Plus
Google Cloud Tech
19 Vector Support on our radar #GenAI
Vector Support on our radar #GenAI
Google Cloud Tech
20 Architecting a blockchain startup with Google Cloud
Architecting a blockchain startup with Google Cloud
Google Cloud Tech
21 Kubernetes and multitasking updates!
Kubernetes and multitasking updates!
Google Cloud Tech
22 GKE: Using Kubernetes Events
GKE: Using Kubernetes Events
Google Cloud Tech
23 How to configure firewall rules for Cloud Composer
How to configure firewall rules for Cloud Composer
Google Cloud Tech
24 Vertex AI Embeddings API + Matching Engine: Grounding LLMs made easy
Vertex AI Embeddings API + Matching Engine: Grounding LLMs made easy
Google Cloud Tech
25 Geospatial analytics on our radar #EarthEngine #BigQuery
Geospatial analytics on our radar #EarthEngine #BigQuery
Google Cloud Tech
26 Ensuring requests are set in Kubernetes
Ensuring requests are set in Kubernetes
Google Cloud Tech
27 Cloud Next 2023, Google research program, and more!
Cloud Next 2023, Google research program, and more!
Google Cloud Tech
28 How to migrate projects between organizations with Resource Manager
How to migrate projects between organizations with Resource Manager
Google Cloud Tech
29 How to run #MySQL in Google Cloud
How to run #MySQL in Google Cloud
Google Cloud Tech
30 #GenerativeAI for enterprises and #Next2023
#GenerativeAI for enterprises and #Next2023
Google Cloud Tech
31 How Google Photos scales to store 4 trillion photos and videos
How Google Photos scales to store 4 trillion photos and videos
Google Cloud Tech
32 Google Cross-Cloud Interconnect (Demo 2)
Google Cross-Cloud Interconnect (Demo 2)
Google Cloud Tech
33 GKE Cost Optimization Golden Signals: Introduction
GKE Cost Optimization Golden Signals: Introduction
Google Cloud Tech
34 GKE Cost Optimization Golden Signals: Workload Rightsizing
GKE Cost Optimization Golden Signals: Workload Rightsizing
Google Cloud Tech
35 GKE Load Balancing: Overview
GKE Load Balancing: Overview
Google Cloud Tech
36 GKE Load Balancing: Best Practices
GKE Load Balancing: Best Practices
Google Cloud Tech
37 Disaster Recovery in GKE
Disaster Recovery in GKE
Google Cloud Tech
38 How to configure IP masquerade agent in GKE Standard clusters
How to configure IP masquerade agent in GKE Standard clusters
Google Cloud Tech
39 Enable and use GKE Control plane logs
Enable and use GKE Control plane logs
Google Cloud Tech
40 Compliance in Australia with Assured Workloads
Compliance in Australia with Assured Workloads
Google Cloud Tech
41 Creating budgets and budget alerts in Google Cloud #FinOps
Creating budgets and budget alerts in Google Cloud #FinOps
Google Cloud Tech
42 Cloud SQL Enterprise Plus on our radar #mySQL
Cloud SQL Enterprise Plus on our radar #mySQL
Google Cloud Tech
43 What's Next for Google Cloud?
What's Next for Google Cloud?
Google Cloud Tech
44 How Loveholidays scaled with Contact Center AI
How Loveholidays scaled with Contact Center AI
Google Cloud Tech
45 What is fleet team management in GKE?
What is fleet team management in GKE?
Google Cloud Tech
46 Troubleshoot VPC Network Peering
Troubleshoot VPC Network Peering
Google Cloud Tech
47 Introduction to DocAI and Contact Center AI
Introduction to DocAI and Contact Center AI
Google Cloud Tech
48 Cloud Run Direct VPC egress explained
Cloud Run Direct VPC egress explained
Google Cloud Tech
49 Database deployment options in GKE
Database deployment options in GKE
Google Cloud Tech
50 Analyze cloud billing data with #BigQuery
Analyze cloud billing data with #BigQuery
Google Cloud Tech
51 Tips to becoming a world-class Prompt Engineer
Tips to becoming a world-class Prompt Engineer
Google Cloud Tech
52 Serverless is simple. Do I need CI/CD?
Serverless is simple. Do I need CI/CD?
Google Cloud Tech
53 Accelerating model deployment with MLOps
Accelerating model deployment with MLOps
Google Cloud Tech
54 How Hawaii's Department of Human Services scaled with CCAI
How Hawaii's Department of Human Services scaled with CCAI
Google Cloud Tech
55 Pricing API on our #Radar
Pricing API on our #Radar
Google Cloud Tech
56 How Recommendations AI for Media can boost customer retention
How Recommendations AI for Media can boost customer retention
Google Cloud Tech
57 Troubleshooting: Node Not Ready Status
Troubleshooting: Node Not Ready Status
Google Cloud Tech
58 One weekend until Cloud Next 2023!
One weekend until Cloud Next 2023!
Google Cloud Tech
59 #GoogleCloudNext starts tomorrow!
#GoogleCloudNext starts tomorrow!
Google Cloud Tech
60 #GoogleCloudNext will be demand!
#GoogleCloudNext will be demand!
Google Cloud Tech

This video teaches advanced AI agent design patterns for building dynamic multi-agent systems, including the loop review and critique pattern, coordinator router pattern, and agent as tool pattern.

Key Takeaways
  1. Design a loop review and critique pattern to ensure output meets specific quality standards
  2. Implement a coordinator router pattern to delegate tasks to specialized agents
  3. Use an agent as tool pattern to treat sub-agents as stateless tools
  4. Test and deploy multi-agent systems using ADK web UI
💡 The choice of agent design pattern depends on the trade-off between control, flexibility, cost, and complexity.

Related Reads

Chapters (6)

Intro
1:09 Pattern 1: The loop pattern (review and critique)
3:08 Pattern 2: Coordinator (Router) Pattern
3:26 Hierarchical Task Decomposition with LLM agent
5:33 Pattern 3: "Agent as tool" pattern
6:49 Recap
Up next
Agentic AI System Design- Complete Roadmap
Aishwarya Srinivasan
Watch →