Multi-Agent Collaboration
Relevant source files
The following files were used as context for generating this wiki page:
In Loom, multi-agent collaboration is a core architectural feature, not an afterthought. Unlike libraries where agents communicate via in-process function calls, Loom agents are independent, long-running services that collaborate across processes and languages using an event-driven paradigm. This enables the creation of complex, resilient, and scalable AI systems.
The foundation of this collaboration is the Rust Core's Event Bus, which provides asynchronous publish/subscribe messaging. This decoupling allows specialized agents to work in parallel, respond to real-world events, and be combined into sophisticated workflows. The system is designed to support long-running agents, event-driven triggers, and cross-process communication, distinguishing it from script-execution-based frameworks.
Sources: README.md:11-15, README.md:41-47, ROADMAP.md:6-10, ARCHITECTURE.md:6-10
Core Architecture
Collaboration in Loom is enabled by two fundamental design principles: the Event Bus for communication and the Brain/Hand separation for agent structure.
Sources: ARCHITECTURE.md:12-14
Event Bus Communication
Agents communicate indirectly by publishing events to and subscribing from topics on a central Event Bus managed by the Rust Core. This pub/sub model allows for asynchronous, cross-process, and even cross-language communication.
This diagram shows how agents interact via the Event Bus without direct connections.
The Event Bus supports different Quality of Service (QoS) levels to handle various communication needs, from low-latency real-time messages to guaranteed delivery for critical tasks.
Sources: README.md:41-47, ARCHITECTURE.md:73-84
Context Isolation
A key feature for effective multi-agent systems is context isolation. Each agent in Loom operates with its own independent context window. This prevents information bleed between agents working on different sub-tasks, avoids token budget conflicts, and ensures that each agent's reasoning process is not polluted by irrelevant information from its peers. This is crucial in parallel workflows like the Deep Research demo, where multiple researchers work on different facets of a query simultaneously.
Sources: apps/deep-research/README.md:13-15, apps/deep-research/README.md:41-51, ROADMAP.md:63-66
This diagram illustrates how different researcher agents maintain separate contexts while only the lead agent aggregates the final results.
Sources: apps/deep-research/README.md:41-51
Collaboration Primitives
Loom provides several high-level interaction patterns, or "primitives," built on top of the Event Bus to facilitate common multi-agent workflows.
Sources: README.md:49-54, core/tests/README.md:16
| Primitive | Description |
|---|---|
request/reply | A correlated request-response pattern with a timeout. |
fanout/fanin | Broadcast a request to N agents and collect K responses. |
contract-net | An agent calls for proposals, other agents bid, and the initiator awards the contract. |
Sources: README.md:50-53, core/tests/README.md:104-105
Request/Reply
This pattern allows one agent to send a request to another and wait for a specific reply. It's used for direct, one-to-one interactions where a response is expected. The system uses correlation IDs to match replies to their original requests.
The sequence diagram below shows a request-reply flow tested in the Loom Core.
Sources: core/tests/README.md:104
Fan-Out / Fan-In
The fan-out pattern is used to distribute a task to multiple agents for parallel processing. A single event is broadcast (fanned-out) to several agents who are subscribed to a topic. The results are then collected (fanned-in) by a coordinating agent.
This pattern is exemplified by the Market Analyst application.
This diagram shows the Market Analyst's fan-out/fan-in architecture. The Data Agent fans out price updates, and the Planner Agent fans in the various analyses.
Sources: apps/market-analyst/README.md:18-25, apps/market-analyst/README.md:121-125
Contract Net
In this pattern, an agent with a task to be done (the "manager") advertises a "call for proposals." Other agents ("bidders") can respond with proposals to perform the task, often including a score or cost. The manager then evaluates the bids and awards the contract to the best bidder.
The sequence diagram below illustrates the contract-net flow, including proposal evaluation and award selection.
Example Implementations
Loom includes several example applications that demonstrate these collaboration patterns in practice.
Market Analyst
The Market Analyst is a multi-agent system for real-time financial analysis. It uses a fan-out/fan-in pattern for parallel processing of market data.
- Data Agent: Connects to an exchange (e.g., OKX) and emits price updates to a
market.price.*topic. - Analysis Agents (Trend, Risk, Sentiment): Three separate agents subscribe to the price topic, perform their specialized analysis concurrently, and publish their findings to
analysis.*topics. - Planner Agent: Subscribes to all
analysis.*topics, aggregates the results, and uses an LLM to generate a trading plan. It has a timeout to ensure it can act even if one analysis agent is slow. - Executor Agent: Subscribes to the
plan.readytopic and executes the trade.
This architecture demonstrates parallel processing and smart aggregation, core tenets of Loom's multi-agent design.
Sources: apps/market-analyst/README.md:12-25, apps/market-analyst/README.md:121-125
Deep Research
The DeepResearch demo showcases dynamic agent spawning and context isolation for in-depth research tasks.
- Lead Agent: Receives a high-level research query from the user. It decomposes the query into several sub-queries.
- Dynamic Spawning: The Lead Agent spawns multiple Researcher Agents in parallel, one for each sub-query. This is achieved by emitting events to specific topics that trigger the creation or activation of these agents.
- Isolated Parallel Research: Each Researcher Agent works independently, using tools like web search. Their context windows are isolated to prevent interference.
- Aggregation: Once the researchers complete their tasks, they emit their findings. The Lead Agent aggregates these partial reports into a single, comprehensive final report.
This demonstrates a powerful pattern of dividing a large task, executing sub-tasks in parallel with specialized agents, and synthesizing the results.
Sources: apps/deep-research/README.md:12-36, apps/deep-research/README.md:62-85
Summary
Multi-agent collaboration is a first-class citizen in the Loom runtime. By leveraging an asynchronous Event Bus, providing clear collaboration primitives, and ensuring context isolation, Loom enables developers to build sophisticated, parallelized, and robust systems of intelligent agents. The architecture moves beyond simple agent-to-agent function calls, promoting a decoupled and scalable model fit for complex, real-world tasks.
Sources: README.md:11-15, ARCHITECTURE.md:6-10