📱

Get Our Mobile App

Take your business learning on the go!

Download on the App StoreGet it on Google Play

Better Agents: How to Build Powerful AI Agents (Using AI)

Code With Nathan9:31

Transcription

What's up everyone? Welcome back with Minaden. In this video, I want to share how you can use Kilo code and better agents to build and orchestrate powerful AI agents.

So, just recently, Langatch introduced a new CLI tool that helps you to build AI agents. It's called better agents and basically the tool generates a set of standard structures and then supercharges your coding assistant such as kilo code or cloud code, making it an expert in any agent framework you choose and all of their best practices. For now, better agents support Agno for Python and Mastra for TypeScript.

When you run better agents, it will generate a clean structure that implements best practices such as prompt versioning for collaboration, automatic agent test scenarios and evaluation, and full observability to track AI application performance. This standard structure also makes it easier to maintain projects for the long run. Here's an example of the structure generated. The source folder is where your agent lives, and then there are folders to organize your test scenarios, evaluations, and prompts. There is the agents.md file to guide your coding assistant on how to develop the project, implement new features, and do proper testing. Next, there is the MCPJSON file, which links to both language and your agent framework documentation so that your coding assistant becomes an expert in your framework of choice and knows where to find new tools. With this tool, you can build better AI agents that are ready for production use.

Next, I'm going to show you how to use better agents with Kilo Code CLI. First, you need to prepare some API keys for the development. The Langwatch API key is used to run agent tests on Langatch. So, sign up for Langatch on their platform. You can use the free tier plan to get started. After that, you can also grab an optional Symmetry API key so that the agent can automatically discover and add MCP tools. They also have a free plan that you can use for your first agent. You also need to have Kilo Code CLI installed. So if you haven't already, you can run `npm install kilo code` command and then set up the tool by providing the Kilo API key. After that, install better agents using `npm install` as well. And once the installation is completed, you can start using better agents to bootstrap your AI agents project. Let me show you how to do that next.

So on the screen here, I have an empty project called awesome agents open in VS Code. Now I'm going to open the terminal here and then run the `better agents init` command. This command will run better agents in the current directory and it will provide instructions to generate your agent project. You can select the programming language. I will select TypeScript for now and then the framework will be Mastra. Next, you also need to provide an API key for your AI agent. This will grant your app access to the AI models. For this demo, I'm going to use OpenAI. So I'm going to select that. And then I will grab the OpenAI API key. If you don't have one already, you can click on this link and then generate API key in the OpenAI platform. Pass the OpenAI API key and then press enter. Now you need to select your coding assistant tool. Here I will select Kilo Code CLI and it will ask for a language API key. So just paste the key provided by Langatch. After that, it will ask for Symmetry API key. So just give it as well. Finally, it will ask what kind of agent we want to build. For now, I will say a goal planner agent that turns a messy input into a structured 5-day plan.

Next, better agents will generate the project as we can see on the left side here and then activate Kilo Code and run it with this specific prompt to build the agent for us. Kilo Code will then start processing the request and then create a to-do list for building the agent. Because we're initializing a new project, it will take longer as Kilo Code needs to bootstrap the agent framework. After that, it will install the required dependencies and once the dependencies are installed, Kilo Code will proceed by generating the prompt that will be used by the agent. After that, it will follow up by implementing the agent in Mastra. Once the agent is created, it will write scenarios for tasks and then run those tasks using Langatch. And we can see the tasks here on the screen. Let's click on one of them to see the details. So the test sends this prompt to the AI and then it responds with a goal summary and a breakdown of a step-by-step plan in 5 days. At the bottom, we can see the scenario test report. The agent passed this test. So great work. And now we can return to the previous screen. And here the agent seems to pass all tests. Next, it will proceed to finish the tests and provide a summary on the terminal. It says the agent is ready for production with full observability, version-controlled prompts, and comprehensive testing.

Let's open the files in the explorer a bit. So here we can see the prompt stored as a YAML file and then the agent itself is written in TypeScript under the Mastra folder and it's being called from the Mastra main index file where the logger and monitor are initialized together with the framework. Okay, we can run the project using `pnpm dev`. This will run Mastra Agent Studio, which gives you an interactive environment for building and evaluating your AI agents. It exposes your agent as a local service that you can interact with. So here I can select the goal planner agent and chat with it. For example, I will say, "Help me learn Mastra and building AI agents." And then after some time, the AI will respond with a 5-day learning plan, breaking down the goal into tasks. There are also estimates on the time required to complete the tasks. Note that the agent is currently using the AI model we selected when bootstrapping the project. It's using GPT-4o mini through the OpenAI API platform.

All right, that's how better agents work in a nutshell. And because of the structure already provided by better agents, Kilo Code now knows how to build on this project. There is the agents.md file here providing guidelines for the agent. So that when you ask it to create a new agent, it will generate the prompt using Langatch CLI tool and then create test scenarios for that agent. Let's try it out. Suppose now I want to create a new agent. And this time it will be an agent that can summarize information from a web page. Also create a tool for fetching web pages from a link for this agent. I will run Kilo Code autonomously here with the `--auto` option. Press enter and let Kilo Code work on the request. It will read the agents.md file for instructions. Now there seems to be an error here, but it doesn't matter as the AI seems to know how to handle the error and then create a to-do list for creating the prompt, implementing the agent, writing scenario tasks, and then running them in Langatch. This will take a while, so I will skip ahead to when it's finished.

And here we have the summarizer agent completed on the terminal. Kilo Code described what it did. And if we open the source folder here, we can see there's the tools folder. It contains the web page fetch tool created for this agent. And then the tool is exported so that the agent can use it. We also have the prompt in YAML format over here. And then there are the test scenarios for the summarizer agent. So next, let's test this agent out. I will run the development server using `pnpm dev` again. And here we can see the web summarizer agent and it has access to one tool as shown on Mastra. Select this agent and then I'm going to ask it to summarize the Kilo Code CLI documentation over here. Copy the URL at the top and then just ask it to summarize this page for me. Send the prompt in and then here's the reply from the agent. We can see that it's using the tool correctly, fetching the web page and then summarizing the content. We can see the tool use detail over here, and then below that, it shows how to install and start the CLI tool as well as highlighting the key features.

Okay, that will be all for this video. Overall, better agents is a useful tool that helps you kickstart your agent development project. It provides a set of folders for structures, organized prompts and test scenarios, and provides guidelines for Kilo Code in the form of agents.md and mcb.json so that Kilo Code knows how to help you in developing the project further. You can check out better agents in its GitHub repository to build your next agent project or use it to improve existing ones. And that brings us to the end of this video. Now you know how to use Kilo Code CLI and better agents to build and evaluate your own AI agents. I hope you all enjoy today's video and get some value out of it. Let me know your thoughts in the comments below. I'll join the conversation and reply as often as I can. If you're new to the channel, my name is Nathan and I help you build profitable apps and projects using AI and other tools. Make sure to subscribe if that's something you find useful. Don't forget to like this video, turn on the notification bell, all that good stuff, as it really helps the channel to grow. With that being said, thanks so much for watching until the end. I hope you have a great day and I'll see you in other videos. Bye-bye.

[music]

[music]