- [Instructor] In this video,
we'll be looking into the power of multi-agent systems
and how the Google ADK framework helps us achieve
these type of systems.
We'll explore how ADK facilitates communication,
delegation, and orchestration between agents,
enabling sophisticated problem solving
beyond the capabilities of a single, monolithic AI system.
But first, let's understand
what a multi-agent system even means.
A multi-agent system is a distributed AI system
composed of multiple agents interacting with one another.
Each agent in the system typically has a specialized role,
capabilities, and goals.
All the agents in the system then work together
to achieve a larger, shared objective
that will be difficult for a single agent to accomplish
on its own.
While a single agent can be powerful,
many real-world problems are too complex
for just one agent to handle effectively.
Multi-agent systems help by mirroring human collaboration,
where different experts come together to solve a problem,
each contributing their own unique skills.
Common characteristics exhibited
by multi-agent systems include:
autonomy, which is the ability of agents
to act independently, social ability,
which means that agents in the system
can interact and communicate,
reactivity, which is the ability of agents
to respond to environmental changes,
and also proactiveness,
where agents can initiate actions to achieve goals
based on current or learned context.
Now let's look at what makes ADK well-suited
for building these types of systems
and why we should use it for developing multi-agent systems
in the first place.
ADK was developed with multi-agent systems in mind,
and it has been authored
to simplify the development process.
"How?" you may ask.
First, by addressing the issue of complexity.
The ADK framework allows breaking down large,
complex problems into smaller, more manageable subproblems,
each handled by a specialized agent.
This reduces the cognitive load on any single agent
and makes the overall system more robust and scalable.
Another attribute is modularity and specialization.
The ADK allows for each agent to be highly specialized
for a particular task.
For example: a researcher agent
can also search the web for information,
a summarizer agent that can feed
from a set of clearly defined criteria for summarization,
and a coder agent that has access to a coding environment
to run algorithms.
This modularity promotes reusability,
easier maintenance, and clearer division of labor
within the AI system.
And lastly, we have robustness and scalability.
By distributing tasks among multiple agents,
the system can become more resilient to failures.
Also, specific agents can be scaled independently
based on demand, thereby optimizing resource usage.
So we have looked at what makes ADK a great fit
for building multi-agent systems.
Now let's look at what it actually provides
to make development of multi-agent systems possible.
And the first one we're going to be looking at
is agent discovery and selection.
When an agent needs help or needs to delegate a task,
it doesn't need to add code-specific agent names.
ADK enables dynamic agent discovery,
where an LLM agent can select the most appropriate subagent
based on the subagent's description and the current query.
These types of agents are called router
or orchestrator agents.
The next feature that makes ADK a great fit
for building multi-agent systems is communication
through the session state management mechanism.
A current agent's run session comes with a state object
that serves as a whiteboard or common memory
for all agents within a particular interaction.
Agents can write to this state object,
typically through the output_key parameter,
as we have seen in previous examples.
Agents can also read from this state object
through the template system in their instructions,
thereby facilitating seamless data exchange.
Asides this state object,
the session also maintains an event history.
This is a chronological log of all messages,
tool calls, and agent responses in the current session.
This can then be served to agents
using the include_contents parameter.
Then we have delegation and orchestration.
The Google ADK allows for two primary forms of delegation:
dynamic, which is LLM-driven,
and deterministic, which is done by workflow agents.
Both of these strategies are crucial
for effective multi-agent systems.
A higher-level LLM agent called a router or orchestrator
can then be configured with a list of subagents.
When it receives a query,
its LLM analyzes the query and a description
of its subagents to decide which subagent is best suited
to handle the task.
This offers great flexibility to the multi-agent system.
On the flip side,
workflow agents provide explicit control
over the flow of their subagents.
This allows developers to define fixed pipelines,
concurrent operations, or iterative processes,
thus ensuring predictable behavior for critical workflows.
This is often used to structure
how fellow LLM agents collaborate.
Finally, in this video,
let's look at a recommended strategy
for building multi-agent systems.
This template will serve as a guide
to help you architect efficient multi-agent systems.
And first is by identifying agent roles.
To design an effective multi-agent system,
you first have to start by identifying your agent roles.
A typical saying in agent development goes thus:
Start with a problem, not the agents.
So before you even begin defining your agent roles,
start by breaking down the complex problem
into distinct, manageable subtasks.
Each subtask can then be assigned to a specialized agent
with a clear name, description, and instruction
that defines its capabilities and persona.
After identifying your agents, you can then move
to defining communication contracts between them.
For agents to effectively collaborate,
define clear contracts for data exchange.
For agents to effectively collaborate,
you need to define clear contracts for data exchange.
This is where the input_schema
and output_schema parameters become vital.
They ensure that data passed between agents
is always in a predictable and validated format.
The next step is to define your orchestration pattern.
You need to decide whether a particular part
of your multi-agent system requires dynamic,
LLM-driven delegation,
for example, for features such as customer service router,
or places where you need deterministic workflow,
such as a document processing pipeline
using a sequential agent.
A large multi-agent system
will often combine both strategies.
Last on the list is hierarchy and delegation.
A multi-agent system can be hierarchical.
This is a situation where a top-level agent delegates
to subagents, and subagents can also delegate
to their own subagents.
Design this hierarchy carefully
to manage complexity and ensure efficient task distribution.
Otherwise unnecessary, avoid deep hierarchies
and complex relationships between different branches.
Keep it simple, well-organized,
and break up steps once you notice complexity creeping in.
In the next video,
we'll be looking at an interesting protocol
that allows inter-agent communication,
helping you stretch your multi-agent systems
beyond your own agentic applications.