Create Swarm
POST /api/agents/swarm/create
Create a new swarm for task execution
Creates a multi-agent swarm optimized for the specified task type. The swarm will be assembled with agents specialized for the task type and will execute the task with the specified priority and agent constraints. Supports various swarm types including code analysis, testing, performance optimization, creative content generation, and more.
@param request: Swarm creation parameters including type, description, priority, max_agents, and timeout @param swarm_engine: Injected swarm execution engine @returns SwarmResponse with swarm_id, status, type, creation time, task description, agent count, and progress @raises HTTPException: If swarm creation fails or swarm engine unavailable
Example Request:
{
"swarm_type": "code_analysis",
"task_description": "Analyze codebase for performance issues",
"priority": "high",
"max_agents": 5,
"timeout_minutes": 30
}Request Body required
Section titled “Request Body required ”Request model for creating a new multi-agent swarm.
Represents a request to create a specialized multi-agent swarm for executing complex tasks requiring coordination between multiple AI agents. Swarms can be configured for different task types with customizable resource allocation and execution parameters.
Fields:
swarm_type: Type of swarm to create (code_analysis, testing, performance, recovery, etc.)task_description: Description of the task to executepriority: Task priority level (low, normal, high)max_agents: Maximum number of agents in the swarmtimeout_minutes: Swarm execution timeout in minutes
Swarm Types:
code_analysis: Multi-agent code review and analysis swarmtesting: Comprehensive testing swarm with multiple test strategiesperformance: Performance optimization and benchmarking swarmrecovery: System recovery and healing swarmcreative: Creative content generation swarmconflict: Conflict resolution and decision-making swarmrisk: Risk assessment and mitigation swarmcode_generation: Multi-agent code generation swarmcleanup: Codebase cleanup and refactoring swarmdata: Data processing and analysis swarm
Priority Levels:
low: Background execution, lowest resource prioritynormal: Standard execution, balanced resource allocationhigh: Expedited execution, prioritized resource access
Usage: POST /api/swarm/create with this model to initiate a new swarm execution.
JSON Example:
{
"swarmType": "code_analysis",
"taskDescription": "Analyze Python codebase for type safety issues",
"priority": "normal",
"maxAgents": 5,
"timeoutMinutes": 30
}
Integration:
- SwarmExecutionEngine: Creates and coordinates the swarm
- Agent Registry: Selects appropriate agents for swarm membership
- Resource Manager: Allocates resources based on priority and max_agents
- Task Queue: Schedules swarm execution based on priority
Responses
Section titled “ Responses ”Successful Response
Response model for swarm operations.
Represents the current state and metadata of a multi-agent swarm, including execution status, progress tracking, and swarm composition details. Used for swarm creation responses, status queries, and monitoring updates.
Fields:
swarm_id: Unique swarm identifierstatus: Current swarm status (pending, active, completed, failed, cancelled)swarm_type: Type of swarmcreated_at: Creation timestamptask_description: Task descriptionagent_count: Number of agents in swarmprogress: Task completion progress (0.0-1.0)
Status Values:
pending: Swarm created but not yet startedactive: Swarm currently executingcompleted: Swarm finished successfullyfailed: Swarm failed with errorcancelled: Swarm cancelled by user or system
Progress Range: 0.0 (0%) to 1.0 (100%), calculated based on completed sub-tasks
Usage: Returned from swarm creation, status queries, and list operations.
JSON Example:
{
"swarmId": "swarm_abc123",
"status": "active",
"swarmType": "code_analysis",
"createdAt": "2024-12-20T10:30:00Z",
"taskDescription": "Analyze Python codebase for type safety issues",
"agentCount": 5,
"progress": 0.65
}
Integration:
- SwarmExecutionEngine: Updates status and progress during execution
- Monitoring Dashboard: Displays swarm state in real-time
- Analytics System: Tracks swarm performance and completion rates
object
Unique swarm identifier
Current swarm status
Type of swarm
Creation timestamp
Task description
Number of agents in swarm
Task completion progress (0.0-1.0)
Validation Error