The AgentRearrange swarm type implements a dynamic architecture where agents can be reassigned to different roles and responsibilities based on task requirements, performance metrics, or changing circumstances. This flexibility allows the swarm to adapt to different scenarios and optimize performance through intelligent role reallocation.Key features:
Dynamic Role Assignment: Agents can switch roles based on task needs
Performance-Based Reorganization: Roles adjusted based on agent performance
Adaptive Architecture: Swarm structure evolves with changing requirements
Flexible Resource Allocation: Optimal use of agent capabilities
curl -X POST "https://api.swarms.world/v1/swarm/completions" \ -H "x-api-key: $SWARMS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Adaptive Content Creation", "description": "Dynamic content creation with flexible agent role assignment", "swarm_type": "AgentRearrange", "task": "Create a comprehensive technical blog post about machine learning in finance, with the ability to reassign agent roles based on content needs", "agents": [ { "agent_name": "Research Specialist", "description": "Conducts research and gathers information", "system_prompt": "You are a research specialist. Gather comprehensive information on machine learning applications in finance, including current trends, use cases, and future prospects.", "model_name": "gpt-4o", "max_loops": 1, "temperature": 0.3 }, { "agent_name": "Technical Writer", "description": "Creates technical content and explanations", "system_prompt": "You are a technical writer specializing in machine learning and finance. Create clear, engaging technical content that explains complex concepts in accessible terms.", "model_name": "gpt-4o", "max_loops": 1, "temperature": 0.5 }, { "agent_name": "Finance Expert", "description": "Provides financial domain expertise", "system_prompt": "You are a finance expert with knowledge of machine learning applications. Ensure accuracy in financial concepts, market analysis, and industry insights.", "model_name": "gpt-4o", "max_loops": 1, "temperature": 0.3 }, { "agent_name": "Editor", "description": "Reviews and polishes content", "system_prompt": "You are a professional editor. Review content for clarity, flow, accuracy, and overall quality. Make improvements while maintaining technical accuracy.", "model_name": "gpt-4o", "max_loops": 1, "temperature": 0.4 } ], "max_loops": 1 }'
Example Response:
Copy
{ "job_id": "swarms-A17nZFDesmLHxCRoeyF3NVYvPaXk", "status": "success", "swarm_name": "Adaptive Content Creation", "description": "Dynamic content creation with flexible agent role assignment", "swarm_type": "AgentRearrange", "output": [ { "role": "Research Specialist", "content": "My research on machine learning in finance reveals key applications in algorithmic trading, risk assessment, fraud detection, and customer service automation..." }, { "role": "Technical Writer", "content": "Building on the research, I've created a comprehensive technical blog post that explains machine learning concepts in finance..." }, { "role": "Finance Expert", "content": "I've reviewed the technical content to ensure financial accuracy, including proper terminology and market insights..." }, { "role": "Editor", "content": "I've edited the content for clarity and flow while maintaining technical accuracy and financial precision..." } ], "agent_rearrangement": "Agents successfully reorganized based on content creation workflow", "number_of_agents": 4, "service_tier": "standard", "execution_time": 38.2, "usage": { "input_tokens": 45, "output_tokens": 2800, "total_tokens": 2845, "billing_info": { "cost_breakdown": { "agent_cost": 0.04, "input_token_cost": 0.000135, "output_token_cost": 0.042, "token_counts": { "total_input_tokens": 45, "total_output_tokens": 2800, "total_tokens": 2845 }, "num_agents": 4, "service_tier": "standard", "night_time_discount_applied": true }, "total_cost": 0.082135, "discount_active": true, "discount_type": "night_time", "discount_percentage": 75 } }}