Everything going on in AI - updated daily from 500+ sources
Emergent Behavior in Agentic Swarms
What building an agentic swarm taught me about control, delegation, and letting go One of the most interesting challenges in designing agents for complex, long-horizon tasks is the ability to maintain a sort of equilibrium between agency and criticism while setting the task goals and striving to achieve them. This is arguably the “art” that drives the quality of the agentic harness. Why is this an “art”? Because it necessitates balancing the opposing forces between advancing forward towards the task goals and processing the correcting feedback. If the scale tips toward advancement, there’s a bigger chance of deviation from the original goals and rules. Too much pulling on the reins and the advancement might stop, tripping the agent into endless loops and companies pay dearly in tokens for this imbalance. The real problem is that there are many cases where it seems this equilibrium is achieved but after numerous cycles, mostly in production where the environment is more diverse than the testing grounds, something along the way knocks the system out of balance. A good agentic system is one that naturally aspires to optimal internal stability across changing external conditions via self-regulation (AKA homeostasis). Fig. 1. Homeostasis between agency and correction. Diagram by author, renderedwith the help of Claude. Homeostasis in any system is achieved via processing a monitoring signal of the baseline behavior. The better the compatibility between the signal (detailed, objective, recent, relevant, clear etc.) and the processing of that signal inside the feedback loop, the more potential the system has to obtain homeostasis. While a single agent needs to self-regulate its inference towards its long horizon goal, when designing composite agentic systems, additional dimensions are added and need to be balanced. Homeostasis in complex agentic systems When you need to design a cluster of agents for a complex task, the ability to divide the task, plan the execution, govern the process, share the data between interdependent phases and validate the outcome can become genuinely challenging. There are several architectures of composite agentic systems. The most basic and common pattern is an orchestrator agent that governs subagents and delegates the work to them and they in turn report back. If you add communication between the subagents, you’ll get an orchestrator and a team of agents that can share findings, coordinate and optimize their working process. The most intriguing architecture to me though, is of an agentic swarm where the architecture is less coherent and when designed correctly, could manifest an emergent implicit behavior. This type of implementation is often not meant for deterministic processes and can be very interesting for tasks that require a high degree of “creativity”. Fig. 2. Composite agentic architectures. Diagram by author, rendered with the help of Claude. I decided to develop an agentic swarm platform to experience firsthand what it takes to create such a system. I started off with sketching what are the main traits of an emergent behavior system. Usually with these systems, the starting point is a set of simple localized rules that guide the interaction between the individual units. The capacity for an emergent behavior is often directly connected to how well these rules balance opposing properties like the one we’ve mentioned earlier about agency and correcting feedback. Governance and task delegation are often opposite forces too. The optimal governance denotes a zero delegation. If an agent is designed for a full governance, it will avoid dividing the task and delegating it because this means a loss of control. If it is designed towards full delegation, it will lose track of the task and inflate the iterations sometimes indefinitely. Another thing worth mentioning is that within complex systems the individual units that comprise it are seldom truly monolithic. Instead, these systems tend to produce an emergent hierarchy that serves the overall functionality. For example: in a beehive the queen emits pheromones that regulate the whole hive activity. It suppresses worker reproduction, inhibits new queen rearing, maintains worker cohesion and modulates the colony’s defensive behavior. In sexually reproducing organisms, development begins with a single fertilized cell called a zygote. The zygote is totipotent, meaning it has the potential to give rise to all cell types of the organism. Through successive rounds of cell division, it forms a solid ball of cells known as a morula. As development progresses, these cells gradually lose their totipotency and become increasingly specialized. As the morula continues to develop, it transitions into the blastocyst stage, where cells communicate through molecular signals. These signals establish positional information that guides cells toward different developmental fates and helps coordinate the formation of the organism’s body plan. Fig. 3. Embryonic cell division. Image by author, rendered with the help of ChatGPT. I decided to loosely model the platform after the cellular division process of a growing organism because this is an emergent behavior that can perform an extremely complex task. The idea was to first start with a stem cell that will be able to create its own specialized type of cells and actively spawn them to achieve the task. Once this will display a dynamic enough expansion, phase two would be to produce a multi stem hierarchy where each one will grow its own sub task-oriented environment. The Tension Between Governance and Delegation The first hurdle I encountered was that LLMs agency naturally tends to self-complete a task. It will not naturally spawn and delegate tasks even if instructed so. LLMs are trained to strive for task completion. In our governance vs. delegation tension, they are leaning heavily toward governance. So, for the most part, phase one was failing to produce rich enough architecture. Even when I pushed hard via the system prompt to divide and delegate the task, this division was minimal and superficial just to comply with the system prompt directive. There have been cases where the main loop did the same work in parallel to the child cells to whom it supposedly delegated the work. That leads to the first principle of designing a swarm emergent behavior: Diversity often comes as an answer to constraints and limitations. As long as my stem cell agent had all the tools to perform the task, it preferred to do that all by itself. This was the easiest and most optimal way to achieve the goal. However, once a stem cell could only design new cells and spawn them but was deprived of web search tools for example, when it was prompted for research, it had to create new cells and delegate . So now the stem cell started to create new cells and delegate subtasks but there was never a real planning behind the task delegation. It was all spontaneous and directly driven by the attempt to work around the constraint. It came to mind that this was mainly from a linear line of work. When it had to invent and spawn new cells, it did so directly in response to the task at hand. Planning, unless specifically designated, is not really a tool that will be created spontaneously. The first principle came in handy here too. If you want a diversified behavior, you need to constrain. Choosing a predefined cell is limiting but it is a lesser effort than inventing a completely new cell. Adding to that the fact that predefined tools could have a description that will suggest when and for what it should be called (i.e. “use this cell when you need to plan for a complex task”) and suddenly planning does occur naturally when needed. So, I added predefined optional cell types on top of the ability to form and spawn a completely new cell type. The decision to keep the two options proved to be the right choice later on. Stepping Into Multi-Hierarchy It was time to move to phase two, from stem cell that spawns specialized cells to a stem cell that can spawn a multi hierarchy set of cells. I used my predefined cells to offer the initial stem cell (called zygote) a set of more specialized stem cells that will manifest specific workflows of processing data. For example: a tournament stem cell, rotating critique stem cell, cartographic stem cell etc. These in turn could spawn their own specialized cells. Keeping the option to invent new types of cells paid off at this point where specialized stem cells that faced a more specific task, could now easily fill in the functionality gap with their own versions of needed cells. When you scale up the number of agents, the next hurdle that becomes apparent is the imbalance between diversity and coordination. Reporting to the parent is not enough. This led to the second principle of agentic swarm systems: Effective agency is tightly coupled with the effectiveness of information sharing among the individual units. Cells need a medium to share information and coordinate. Asking the organism for simple tasks like forming a chain of five stem cells meant each cell needed to figure out its location in the chain and coordinate the spawning of additional cells until the final goal is met. This required communication skills far beyond a child completing a task and reporting results to its parent. Multiple messages needed to be passed throughout the chain. This was one of the most challenging tasks. Too much communication meant the agentic loop had to deal with excessive noise, and the work thread could easily be lost. I gave the platform a simple message bus. Potentially any cell can communicate with any other cell, but it needs to initiate a message. There were no mass public channels that will spread noise. Given the inherited linear processing of an LLM, almost all the communication happens between a parent cell and its children, keeping the information processing localized to a specific area, which is optimal in terms of agentic loop unnecessary noise. When cells started to communicate, the context window soon became a limitation. Context window management is a significant challenge across LLM systems broadly, with many different approaches and solutions. For this platform, I implemented a basic but effective solution for memory management in the form of key-value artifacts that cells could share with each other as a whiteboard, and added content compression when the context window exceeded a certain percentage of the max context window configuration. Designing for Implicit Control Now that swarm diversity has gone up and the cells could communicate effectively, governance that was nonissue on the single agent scale, became a huge problem on the overall swarm system scale. Once tasks had been delegated to subagents that in turn delegated them to additional cells, I could see that things are getting out of control. The formed organism could expand too much creating unnecessary and excessive work. Cells entered never ending processing loops that kept digging deeper into a task without any ability to know when and how to stop. So now I had a swarm, but I seldom got anything productive back from it. That led me to the third principle of designing an agentic swarm: Implicit control over a swarm is done over the design of a resource economy. In the single agent scale we’ve talked about homeostasis between critics and agency. This is an explicit tool that impact directly inside the agentic loop. Implicit control might sound as an oxymoron but looking at every complex system, this type of governance is done by regulating agency externally. The monetary system, for example, uses interest rates to regulate the flow of money and with that the whole economy. In biology, every action cost energy. Controlling the energy flow in the system would result in the type of governance I was looking for. I implemented an energy system where every cell is given an energy units budget from its parent. When it acts, it consumes the units and if running low, it can ask for additional energy, or it must end whatever it is doing and report back. The energy management was a game changer. It created a very flexible governance with which you could affect the size of the organism and the complexity of the task execution. Adding the option for different cost for every tool and cell type, I could implicitly favor certain tools and cells over the others. While playing with this option I noticed that if the energy flowed in only one direction, from parent to child, it created a very limiting effect on the possibility of structure developments. The system became very conservative in the way it handled processing and new spawning very similar to the “too much governance and no delegation” as it tried to preserve energy units. The flow had to go both ways. An organism spends energy on action, but it gains energy too when it consumes food. I figured that if a child cell has been able to complete its work, letting its parent harvest energy units from the outcome might encourage the parent to delegate more tasks and contradict its inherited behavior of self-dealing with the task. Furthermore, by tuning the rate of energy returned, the system could dynamically strike a homeostatic equilibrium. This indeed created a much better energy flow and resulted in a balance between the complexity and diversity of the system while maintaining the ability to receive highly practical products from the processing. What still surprise me in this project, sometimes to a point of frustration, it that engineering emergence is a different type of engineering. It’s similar to what it takes to be a good manager. You cannot be a good manager via forced control and micromanagement, you need to design the environment in which your organization grow. If you want to explore this space yourself, the platform is open-sourced on GitHub as zygote-oss (MIT licensed). It’s particularly well-suited for tasks where the solution space is genuinely open-ended and creativity matters more than determinism. Emergent Behavior in Agentic Swarms was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.
Read Original Article →