SUBMIT A PRLAST EDIT : Feb 17, 2025
Swarm Network Integration
Overview
The Swarm system enables decentralized communication between AI agents through a central orchestrator. This framework provides actions to interact with agents registered on the Swarm network.
Architecture


-
Swarm Orchestrator: Central hub that:
- Maintains agent registry
- Routes messages between agents
- Provides agent status information
- Stores agent data
-
Agents: Autonomous entities that:
- Register with the orchestrator
- Store data through the network
- Communicate with other agents
- Maintain their own API endpoints
Available Actions
1. SwarmMessage (SwarmMessage.ts)
Purpose: Send messages to other agents on the network
Usage:
const result = await executeAction("SwarmMessage", {
agentIdToReach: "target-agent-id",
message: "Your message here"
});
Parameters:
agentIdToReach: Target agent's unique identifiermessage: Content to send
Validation:
- Automatically checks if target agent is online and ready
2. SwarmGetData (SwarmGetData.ts)
Purpose: Retrieve data stored by an agent in the last hour
Usage:
2. SwarmGetData (SwarmGetData.ts)
Purpose: Retrieve data from an agent on the network
const data = await executeAction("SwarmGetData", {
agentAuthority: "target-agent-id"
});
Parameters:
agentAuthority: Target agent's authority identifier
Core Service Methods (SwarmService.ts)
| Method | Purpose |
|---|---|
getAgentStatus() | Check if an agent is online and ready |
sendMessageToAgent() | Route message through orchestrator |
getDataStoredByAgentLastHour() | Retrieve temporal data |
getAgentsOnNetwork() | List all registered agents |
storeAgentOnNetwork() | Register new agent |
How it works


Implementation Details
- Dependencies:
constructor(container: DependencyContainer) {
this.swarmService = container.get<SwarmService>("SwarmService");
}
- Error Handling:
- Automatic error logging through Iryna logger
- Unified error format in responses:
return { success: false, error: error.message };
- Message Flow:
- Validate target agent status
- Package message payload
- Route through orchestrator
- Return response to caller
Requirements
Environment Configuration:
SWARM_ORCHESTRATOR_URL=http://your-orchestrator:port
Best Practices
- Always check
successboolean in responses - Wrap calls in try/catch blocks
- Use built-in validation before operations
- Monitor logs through
irynaLoggerintegration