[0:00]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.
[0:18]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, open source and modular framework for developing and deploying 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 this amazing resources in the description below. In this video, we'll see how we can get started and run your first TypeScript agent in about five 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 NPM or yarn. ADK also has a dev UI to help you prototype and debug your agents with a chat interface. So if you want to use it, you can also add this extra dependency, dash dev tools. All right, once you have the dependency, the most fundamental concept you'll work with is the notion of agent. There are three main categories of agents: LLM-based agents, workflow agents, and custom agents. LLM-based 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 concept. 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 agent's 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 chat bob 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 a talentry. I'm my TypeScript project setup. 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.
[4:18]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. It's 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 opened the web UI. You can see in this job 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 stream as it's being generated. Why is the sky blue? Something that my son will ask. What's interesting is that it's stream.
[5:14]You can see the events that are flowing through. 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 so 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 weights agents bridge that gap. Tools are supported by capability of LLMs 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 tools 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 tool 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 tool to document its purpose and define its parameters with a schema. This helps the LLM figure out when to call that function and what parameters the function expects. Then you can return some structured response, which will be serialized into a JSON object and passed 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 tool where we define the extra tool to the agent. For the function tool, we use Zod 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 1234. The function was called. The tool was called, and the answer was received, and you can see the various events here. So the initial event like the question that was asked, then the tool was called, its execution came back, and we then give the answer. You can go back and forth and see what was generated. It's very convenient 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 agent's purpose, its persona, its 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 world 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-agent systems. We can have multiple agents collaborating together in a multi-agent scenario. TypeScript ADK supports extensibility through MCP and A2A, agent-to-agent protocols. We'll talk more about these in the other upcoming videos. But for today, let's explore multi-agent architectures and how ADK allows you to implement them. A parent ADK enables, is allowing one agent to use another agent as a tool. This agent tool concept let's 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 the summarizer agent we have just defined to create summaries of long text as requested by the user. The agent tool 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 LLM-based agent. But for more prescriptive multi-agent 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 agent's logic, then workflow agents are certainly the way to go. As it makes the execution flow of the multi-agents more deterministic. We can use a sequential agent to change sub-agents together, where the output of the previous agent becomes the input of the following agent. And the sub-agent itself can be another flow, another LLM agents, etc. There's also parallel agents. The difference is that the sub-agents are executed in parallel, not sequentially. For example, summarizing a collection of books in parallel and we can combine their output. The third sub-category 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 sub-tasks, or require different areas of expertise. For 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, required 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 unique ID, an application name, and a user ID. They also store the history, a shared 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 is the state. This is our agent's temporary scratchpad, 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 loaded by the session service. Some values can have specific prefixes to instruct the session 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 instruction, using simple templating syntax with the curly braces placeholders, making this agent a 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.



