Transcription
There's a fundamental problem with AI coding agents. They get dumber the longer they work. You probably have noticed that the details blur and the quality also decreases substantially.
Now, Enthropic's answer to this is to stop using one agent and start using five or more. Their first attempt at solving this was the introduction of sub-agents. When Cloud Code needs to research something or do a quick task, it creates these lightweight workers called sub-agents, and it does a task and returns the summary.
Now, this is great in theory, but it breaks down if these sub-agents need to communicate with each other. To solve this, Anthropic is introducing the concept of agent teams. These are essentially multiple different instances of Cloud Code which are able to communicate with each other. So, let me break it down for you.
Here is the normal architecture of a Cloud Code sub-agent. You have the main agent or orchestrator at the top. It assigns tasks to individual sub-agents. The agents individually perform those tasks and then they report back the results to the main agent. This separation of concerns works best if you have focused, isolated tasks.
However, say one sub-agent researches your authentication system and another is looking at your database layer, and they find something that connects. It's a really bad situation because they don't know that there is an independent other sub-agent that is working on something. So, both of them can make changes to this one codebase.
Now, this is why Enthropic is introducing the concept of agent teams. Now, in this case, you have the main agent or team lead instead of a simple orchestrator. You have a shared task list that all the agents are able to see. Then, each of the teammates is essentially an independent instance of Cloud Code. It has its own context. But the beauty is that each one of them can not only see this shared task list, but they can also communicate with each other, and they can also communicate with the team lead at the top. Not only that, as a user, you can directly ask or communicate with each team member independently. So, this is an extremely powerful design pattern that you can use in your own software applications.
Now, but one thing, the idea is not to replace sub-agents because they have their functionality and use. Using this design pattern, an engineer at Anthropic built a completely working C compiler over 2,000 Cloud Code sessions and with a $20,000 API cost.
Okay, so I'm going to show you how to use this in Cloud Code. But let's talk about the main differences of sub-agents versus agents and when to use what. For sub-agents, each one of them has its own independent context window. For agent teams, every team member has also an independent context window. We talked about communication and coordination.
Now, sub-agents are best for focused tasks where only the results matter and you are not interested in cross-communication of your agents with each other. This is best when working on a complex task which requires discussion and collaboration. It's really great for complex problems. But here's the main thing. This is going to be running multiple different instances of Cloud Code with their own MCP servers connected, their own skills. So, you're going to be paying a lot more in token cost compared to sub-agents. So, just don't go and start an agent team if you don't need one.
In terms of the architecture, there are four different components. The first one is the team lead. This is the main Cloud Code session that creates the team and it talks and coordinates work across different team members. Then you have the team members, which are separate Cloud instances that each work on assigned tasks. There's a shared task list, which is basically the to-do items that a team member is going to work on. And then there's a mailbox, which is a messaging system for communication between agents. Now, all of this is happening through files on your local system. It's simply a list of different MD files or JSON files which coordinates everything on your local system.
Okay. So, let me walk you through a setup process. You can run this in a terminal, but if you want to be more interactive, I highly recommend to use T-Max because then you're going to see this split view of different agents working in parallel. And you can also chat or communicate with every agent or team member individually.
This is an experimental feature that is not enabled by default in Cloud Code. So, you will need to enable it. And the way you enable it is that you'll need to go to your settings.json file and just update this new feature in there. But there is actually an easier way. Just copy this command and tell Cloud Code to set this up for you.
On my machine, I have T-Max installed. So, we're going to just start that. And now I need to start Cloud Code. So, here I'm starting Cloud Code within T-Max. So, you're going to see the normal interface of Cloud Code.
So, here's an example prompt that we're going to try. Now, in this case, I want to create a full-stack habit tracking app. It needs to use Next.js and SQLite for the database. When you are working with agent teams, you can either tell it what team members you specifically want. Right now, we are looking for four different teammates. Or you can keep it open-ended and let Cloud decide how many team members to create. So, I'm going to just copy this.
So, right now, this Cloud instance is running inside T-Max, and the idea is that when it starts multiple different team members, you are going to be able to see them work. Now, the beauty is that since there can be a dependency of one team member on the other one. So, you can actually see in cases where the system or one of the Cloud instances is waiting for another team member to complete some work because of this intercom communication that is happening.
Okay. So, right now, it's trying to spin up four different team members, and on the right-hand side, you can actually see that they have started working. So, right now, the architect is waiting for our input. Also, you're going to see that the other ones are blocked by that. So, we're going to provide input to the architect.
Now, you can actually send individual messages to different team members. So, let's say I want to check with the backend API setup. And here's the response that I got. So, it's still standing by and it's ready to go as soon as the architecture is complete. We still see that the architecture is still being worked on, and we can actually see the team lead is communicating with different agents in the process.
Now, here's an example of a Storybook that this multi-agent system is building. Now, the beauty of this architecture is that it goes beyond a simple coding agent. Especially if you look at projects like Open-Code, you can have a personal assistant that is created on top of Cloud Code or the Cloud Agent SDK that can create agents on demand.
Okay. So, for display mode, right now we were using the split panes. This is supported in iTerm2 or T-Max. But if you try to run this in a normal terminal or within VS Code, you're going to be running it in the process mode where you're not going to see these multiple different agent agents working together, but you can still use the shift up and down to select a teammate and communicate or message them individually if you want to.
Okay, so let's talk about some practical things to consider when you are building with agent teams. So, in this section, we're going to be covering a blog post from Eddie Usmani, who is a director at Google Cloud AI. Now, when you are assigning tasks to sub-agents, think about yourself as a technical manager, and this is the role I have adopted in my own coding styles.
Now, for sub-agents, according to Usmani, the task sizing matters. If you assign too small of a task, then the coordination overhead that you're going to have is not worth it. For too long or too large of tasks, the agents are going to risk wasted effort and they're probably not going to check in with each other. So, his rule of thumb is to work on self-contained units and produce clear deliverables.
Another thing that you still need to worry about is file ownership. If there are multiple teammates working on the same file, you need to be very careful about who touches which file and when. So, ideally, you want to create agents that are going to be working on different files at the same time.
Now, there is a little discrepancy with the way the context is loaded into the sub-agents. So, all of them are looking at the CLOUD.md file, which is at the root of the project, and it has access to all the MCP servers and skills, but they don't inherit the lead's conversation history, which can create some disconnect, and that's why Usmani recommends to include task-specific details in the prompt of your teammates.
Now, a few other things that he has noticed that sometimes the lead will start implementing instead of delegating the tasks. That's not supposed to happen, but because of the nature of the LLMs or agents that can be triggered. Right now, this is an experimental feature. Task status can lag, and there is one team per session. You cannot have nested teams.
I actually like this section about a word of caution, and this applies to any multi-agent system and not just the implementation that Anthropic has. In most of the cases, if you have multiple different agents working on a codebase, the amount of code that is going to generate is going to increase substantially. But this added activity does not translate to value. You want to still keep them very focused on specific tasks, just like the way you would do sub-agents. And more importantly, don't just try to use the latest features that are available. Your problem should guide the tooling, not the other way around. You probably don't need these teams for every task. And keep in mind, it's not only just going to have added complexity, but you're going to be running through your tokens like crazy.
All right, this was a quick overview of this new agent teams feature in Cloud Code. Still, it's an experimental feature, and I would suspect there are going to be some huge updates coming in. From my initial testing, it's a very promising feature that you want to keep an eye on. Anyways, I hope you found this video useful. Thanks for watching, and as always, see you in the next.