Loading video player...
Hi, Mandy here. I'm excited to announce
the TypeScript ADK. Yes, our agent
development kit is now available for
TypeScript and JavaScript developers.
And in this video, we're going to learn
all about what it is, how it works, and
how you can get started.
As you might know, building AI agents
from scratch, dealing directly with LLM
APIs or SDKs can quickly become complex.
You're managing state, memory, two
calls, control flow, and more. Often
reinventing the wheel for common
patterns. That's precisely what agent
development kits or ADK is designed to
address. ADK is a flexible and modular
open-source framework specifically built
to simplify the development and
deployment of AI agents. We already have
an introductory video about ADK and also
a set of workshop videos that go through
samples and examples of how to use ADK.
You can find links to these amazing
resources in the description below. In
this video, we will see how we can get
started and run your first TypeScript
agent in about 5 minutes and then we
will dive deeper into some of the more
advanced concepts. First step, as with
any library, is including ADK in your
project. When using TypeScript, this
means adding the necessary dependency to
your package JSON file. You can do this
easily using MPM or YAN ADK also has a
dev UI to help you prototype and debug
your agents with a check interface. So
if you want to use it, you can also add
this extra dependency -ashdev tools. All
right. Once you have the dependency, the
most fundamental concept you work with
is the notion of agent. There are three
main categories of agents. LLMbased
agents, workflow agents, and custom
agents. LLMbased agents use LLM for
reasoning, deciding which tools to call
or which agents to transfer to. Workflow
agents are for more prescriptive or
deterministic logic flows. Finally,
custom agents where you can code your
own way with your own logic. And of
course, you can compose them all
together for more advanced scenarios.
How would you define an LLM agent?
Here's a simple example to create a
helpful assistant to let student ask
questions about scientific concepts. You
create a new LLM agent instance passing
it a configuration object where you
define a name, a description, the LLM
model you want to use and some
instruction that define the agents role.
Now let's see how you can execute this
agent. We have got a dev UI if you want
to prototype and debug your agent with a
visual web console. But first, we'll
quickly show you how to set up some code
to run your agent programmatically and
execute your agents from the command
line. Here we are still in the main part
of your application. To run the agent,
we'll need a runner and a session. The
runner acts as the central coordinator
for your app and the session will hold
the conversation state. In order to take
questions from the user, we'll use a
while loop. If the user want to stop,
they can type quits at any time to end
the conversation. Then we take the
user's input, pass it to the agent, and
get back a response which is returned as
a list of events where each event
represents a chunk of the final
response. Finally, we loop over all the
asynchronous events forming the response
from the agent and we have got a
familiar chatbot loop interaction. Now
you can use ts node to run the agent
directly from the typescript source
file. This command compiles and executes
your code in one step allowing you to
immediately start interacting with your
agent. Let's see everything in action
inside.
I have my TypeScript project set up. I
have a package JSON file with the
dependencies on the Google ADK framework
already defined.
I have my science teacher agent which is
right there with its definition and the
main ts file with a while loop to go
through the input from the command line.
Let's run this.
I'm going to say hello
and then I'm going to say what about
quantum computing?
Let's see what it says. It's a long
answer. is a complicated topic, right? I
can then quit.
And what about seeing this in the dev
UI? So, I have another command here to
run the dev UI to interact with my
agent.
I open the web UI. You can see in this
drop-down menu, we have the science
teacher agent load up. I'm going to say
hello again.
And I can enable token streaming if I
want to see the response being streamed
as it's being generated. Why is the sky
blue? Something that my son will ask.
What's interesting is that it stream
you can see the events that are flowing
through like the first one was a hello
and then the question and when you click
on it you can see the events from ADK.
This is great. Now, let's dive a little
deeper. We have created your first agent
in Typescript and saw how to run it
successfully. However, the agent lives
on its own island. It's time you let it
interact with the external world via
tools. Think about it. A large language
model is incredibly powerful with text
or multimedia elements, but it cannot
natively browse the internet, query your
database, send an email, or call an
external API. Tools are the ways agents
bridge that gap. Tools are supported by
a capability of LLM's call function
calling. Your agent receives a user
request. The LLM analyze it, determines
if an external action is needed, and
decides which register tool to use along
with the arguments for that tool. ADK
framework then intercept this function
call from the LLM executes the
corresponding code or action you have
defined for that tool and finally the
tool's result is sent back to the agent
usually to the LLM again so it can
process the result and formulate the
final response to the user. ADK
abstracts this away providing a clean
interface for defining tools and
handling that entire execution loop for
you. Typescript ADK provides three types
of tools for your agent to use. Function
tools with your own code, built-in tools
like Google search, third party tools
like the ones provided by MCP service.
So let's talk about function tools. A
function tool essentially wraps a piece
of your code a method and makes it
available to the agent. Okay, we have
created a science teacher agent. Now
let's create a customer agent. As usual,
we give it a name, a LLM model to use, a
description, and some instructions about
its role. But this time, we also provide
a tool to let customers ask about the
status of their orders. How to declare
the existence of that tool? We create an
instance of function two and pass it a
configuration object that defines its
name. Now, let's see how to create that
function. You define a TypeScript method
which will serve as your external
function that the agent needs. You
provide a description for the to
documents its purpose and define its
parameters with a schema. This helps the
LM figure out when to call that function
and what parameters the function
expects. Then you can return some
structure response which will be
serialized into a JSON object and pass
back to the LLM agents. Let's have a
look at this customer agent.
I define my agent here
and we create an instance of the
function two where we define the extra
two to the agent. For the function two,
we use saw to define the parameter
schema of the function. Let's run this
through the dev UI which is already
running.
Now in the dev UI, let's say hello.
Let's ask for the status of my order. 1
2 3 4 the function was call
the two was call and the answer was
receive and you can see the various
events here.
So the initial event like the question
that was asked
then the two was called
it execution came back and we then give
the answer
you can go back and forth and see what
was generated. It's very convenience to
understand what's going on within your
agents as you develop it when you want
to debug it. It's critical to give
precise and explicit instruction to
define the agents purpose, his persona,
his goals, and to provide guidance in
how it should interact with the user and
the tools. The tools should also be
described with great detail so that the
LLM clearly understand its purpose and
its arguments. By equipping an LLM agent
with tools, you have got a functional
agent capable of understanding natural
language requests and performing actions
on the external role through the tools
you have defined. This form the
essential foundation for building more
complex and capable agents in
Typescript. But now let's move from
single agents to the world of multi-
aent systems. We can have multiple
agents collaborating together in a
multi- aent scenario. Typescript ADK
supports extensibility through MCP and
A2A agentto aging protocols. We'll talk
more about these in the other upcoming
videos. But for today, let's explore
multi-aging architectures and how ADK
allows you to implement them. A pattern
ADK enables is allowing one agent to use
another agent as a tool. This agent to
concept lets you build hierarchical or
collaborative system where agents
delegate tasks to others. Let's say your
main agent needs a tool to create
summaries of long text. We can define a
summarizer agent like this. Let's define
our main agent to be a helpful
assistant. And we'll also instruct this
agent to use a summarizer agent we have
just defined to create summaries of long
text as request by the user. The agent
to class will transform a summarizer
agent into a tool that the main agent
can invoke when needed. ADK's agent tool
provides a clean standardized interface
for this interaction between the agents,
abstracting away the underlying
communication mechanisms. We have just
seen how to use an agent as a tool with
an LMMbased agent. But for more
prescriptive multi- aent systems, ADK's
workflow agents are essential for
orchestrating complex flows involving
multiple agents. There are three
workflow agents, sequential, parallel,
and loop agents. There's also a
possibility of creating some custom
logic based agents, but we'll save that
for another video. Let's zoom in on the
workflow agents for a moment. If you can
draw a flowchart for a part of your
agents logic, then workflow agents are
certainly the way to go as it makes the
execution flow of the multi- aents more
deterministic. We can use a sequential
agent to chain sub agent together where
the output of the previous agent becomes
the input of the following agent and a
sub agent itself can be another flow and
other LM agents etc. There's also
parallel agents the difference is that
the sub agent are executed in parallel
not sequentially for example summarizing
a collection of books in parallel and we
can combine their outputs. The third
subcategory of workflow agent is the
loop agent which can run a sequence of
agents in a loop for a specified number
of iterations or until some termination
condition is met. For example, you might
have a story writing system that takes
an initial draft and iteratively add
details only exiting when a critique
agent is satisfied with the final
output. Multiple agents enabled by ADK
are ideal for complex problems that
naturally decompose into smaller, more
manageable subtasks or require different
areas of expertise. For a customer
support system, you might use several
agents like one for answering frequently
asked questions, one for escalating
complex issues to a human and another
one for processing refunds. This
approach offers modularity and can make
the system easier to develop and
maintain. Although there might be some
overhead in communication or latency.
Choosing the right approach depends on
the problem scope require flexibility
and need for distinct areas of
intelligence or capacity. A key aspect
for handling complex ongoing
interactions is context and knowledge
management. ADK provides comprehensive
tools for managing this. Now let's talk
about the conversational context
concept. There are three components
here. Session, state, and memory. Let's
break it all down and we will talk about
sections and state. Sessions help you
manage multiple conversations for
different users and applications. They
have key identifiers like unit ID, an
application name, and a user ID. They
also store the history, a share state
map, and tell you when the last event
happened. The session maintains a
history of all interactions, messages,
two calls, result, etc. as a sequence of
events. And within the session, there's
the state. This is our aging temporary
scratch pad, a place to store data
specific to this particular
conversation. Store values you store in
the state are serializable which means
convertible for data storage or transfer
ideally with basic types or simple
collections of them so they can be
easily saved and load by the section
service. Some values can have specific
prefixes to instruct the section service
about their life cycle. Let's look at
how you can specify the initial state of
the science teacher agent we have
created before. To make it more
generalizable, we can specify the state
map when creating the session by
specifying the subject of the teacher
and also the audience. Then in the agent
definition, you can access the state
directly within your agent instructions
using simple templating syntax with the
curly braces placeholders, making this
agent more generic one accepting
different subjects and audiences. And
that's all we have time to cover today
about agent development kits for
TypeScript. Check out the TypeScript ADK
documentation, our sample examples, and
our past videos and start building
today. Remember, by combining workflow
orchestration multi-agent
collaboration, and robust state and
memory management, ADK provides building
blocks to create sophisticated AI agents
for your most challenging problems.
Don't forget to tell us in the comments
how you're planning to use the
TypeScript ADK in your project. See you
in the next one.
Learn about Agent Development Kit (ADK) for Typescript, an open-source, modular framework designed to simplify the development and deployment of AI agents for TypeScript and JavaScript developers. Get started today and build your first Typescript agent for your AI application. Resources: Learn more about the Agent Development Kit → https://goo.gle/4rS7wOC ADK documentation → https://goo.gle/4rS7wOC ADK Typescript code → https://goo.gle/4oOZQKo Chapters: 0:00 - Introduction 1:50 - Defining Agents 3:54 - Agent Demo 5:40 - Tools 8:09 - Customer Service Agent Demo 9:51 - Multi-agent systems 11:30 - Workflow Agents 13:28 - Conversational Management Services 15:08 - Outro and next steps Subscribe to Google For Developers → https://www.youtube.com/user/GoogleDevelopers #AIAgents #ADK #GoogleCloud