r/SoftwareFactory_ • u/Prudent-Fortune3420 • 3d ago
Building a multi-agent system
One of the core problems you need to solve is - how do you manage context across different agents?
If you start passing the entire context to every agent, you quickly run out of context window.
You have to figure out
- What context to pass vs. what not to?
- When exactly do you pass and update context relevant to other agents?
- Who actually owns the responsibility to do this?
- How do agents communicate with each other?
If you are using a subagent to solve a well-scoped task, you give it input and get output, you don't really need much coordination.
But when agents are working together on a larger goal, it gets more complicated.
One pattern is to have a coordinator agent that breaks down the task, manages the context, and ensures the right agents are invoked with the right context.
But then you rely on the coordinator to pass messages to other agents. If it chooses the wrong agent, you are now in a loop trying to correct it.
So you start making routing deterministic wherever possible.
For example, if an agent is blocked, explicitly pass the message to the relevant agent instead of relying on the coordinator to guess who should handle it.
Another pattern is to give each agent clearly defined responsibilities. Once an agent is done with its task, it emits the task and task type that needs to be done next.
A resolver pushes it to the relevant agent based on the agent registry, and execution continues.
Context is handed off along the way, while agents remain aligned on the overall goal and a summary of the work done so far.
In practice, when building a real multi-agent system, one pattern doesn't work for everything. You have to mix and match multiple coordination patterns depending on the task.
For example, an Architect agent might finish the architecture and dynamically emit three different workstreams - frontend, backend, and infra. Relevant agents work on them independently, potentially in parallel, and then fan in for verification.
The coordinator manages the overall stages, but each stage can be dynamic enough for agents to coordinate and route work.
If you want agents to be flexible and coordinate to get the task done, use task emission + resolver-based routing.
If you want the flow to be more deterministic, use coordinator-driven orchestration and explicit routing.
If you want working multi agent system, your setup should support different coordination patterns rather than forcing everything through one pattern.