-
-
Notifications
You must be signed in to change notification settings - Fork 9
Task Distribution
Understanding how Agentwise allocates work among specialized agents for optimal performance.
Task distribution is the core orchestration mechanism in Agentwise that intelligently assigns work to the most appropriate agents. This system ensures maximum efficiency, parallel execution, and optimal resource utilization.
The central orchestrator analyzes incoming requests and makes intelligent decisions about task allocation:
User Request β Analysis β Task Decomposition β Agent Assignment β Execution β Integration
- Task Analyzer: Breaks down complex requests into manageable tasks
- Agent Matcher: Identifies the best agents for each task
- Load Balancer: Distributes work based on agent availability
- Dependency Manager: Handles task interdependencies
- Progress Monitor: Tracks execution and handles failures
The orchestrator first analyzes the user request to understand:
- Project Type: Web app, API, mobile app, etc.
- Technologies: React, Node.js, PostgreSQL, etc.
- Complexity: Simple, moderate, complex
- Requirements: Features, constraints, preferences
// Example request analysis
{
"request": "Build a full-stack e-commerce platform with React and Node.js",
"analysis": {
"projectType": "web-application",
"technologies": ["react", "nodejs", "database"],
"complexity": "high",
"estimatedTasks": 12,
"requiredAgents": ["frontend", "backend", "database", "testing"]
}
}
Complex requests are broken down into atomic tasks:
// Task breakdown example
{
"tasks": [
{
"id": "task-001",
"type": "frontend",
"description": "Create React project structure",
"priority": "high",
"dependencies": [],
"estimated_tokens": 5000
},
{
"id": "task-002",
"type": "backend",
"description": "Set up Express.js API server",
"priority": "high",
"dependencies": [],
"estimated_tokens": 6000
},
{
"id": "task-003",
"type": "database",
"description": "Design product and user schemas",
"priority": "medium",
"dependencies": ["task-002"],
"estimated_tokens": 4000
}
]
}
Each agent has defined capabilities that are matched against task requirements:
// Agent capability matrix
{
"frontend-specialist": {
"technologies": ["react", "vue", "angular", "svelte"],
"skills": ["ui-design", "state-management", "responsive-design"],
"priority_tasks": ["component-creation", "styling", "routing"]
},
"backend-specialist": {
"technologies": ["nodejs", "python", "go", "java"],
"skills": ["api-design", "authentication", "data-processing"],
"priority_tasks": ["server-setup", "endpoint-creation", "middleware"]
}
}
Distributes tasks evenly across available agents:
Task 1 β Agent A
Task 2 β Agent B
Task 3 β Agent C
Task 4 β Agent A (cycle repeats)
Assigns tasks based on agent performance and capacity:
{
"agents": {
"frontend-specialist": { "weight": 0.4, "capacity": 3 },
"backend-specialist": { "weight": 0.3, "capacity": 2 },
"database-specialist": { "weight": 0.2, "capacity": 1 },
"testing-specialist": { "weight": 0.1, "capacity": 1 }
}
}
High-priority tasks get precedence and faster agents:
{
"priority_mapping": {
"critical": ["frontend-specialist", "backend-specialist"],
"high": ["database-specialist", "devops-specialist"],
"medium": ["testing-specialist", "research-agent"],
"low": ["documentation-agent"]
}
}
Tasks often depend on outputs from other tasks:
// Dependency graph
{
"dependencies": {
"frontend-components": ["api-endpoints", "data-schemas"],
"api-endpoints": ["database-schema"],
"testing-suite": ["frontend-components", "api-endpoints"],
"deployment": ["testing-suite"]
}
}
The orchestrator creates an execution plan that respects dependencies:
Phase 1: [database-schema] β database-specialist
Phase 2: [api-endpoints] β backend-specialist
Phase 3: [frontend-components, testing-basic] β frontend-specialist, testing-specialist
Phase 4: [integration-tests] β testing-specialist
Phase 5: [deployment] β devops-specialist
Tasks without dependencies can run in parallel:
// Parallel execution groups
{
"parallel_groups": [
{
"group": 1,
"tasks": ["database-schema", "project-setup", "design-system"],
"agents": ["database", "devops", "frontend"]
},
{
"group": 2,
"tasks": ["api-endpoints", "ui-components"],
"agents": ["backend", "frontend"],
"depends_on": [1]
}
]
}
The system can reassign tasks based on real-time conditions:
- Agent Availability: Reassign if agent becomes unavailable
- Performance: Move tasks to faster agents
- Workload: Balance load as new tasks arrive
- Failures: Retry with different agents
// Dynamic reassignment example
{
"event": "agent_unavailable",
"agent": "frontend-specialist",
"action": "reassign",
"tasks": ["task-005", "task-007"],
"new_agent": "frontend-specialist-2",
"reason": "load_balancing"
}
Each agent maintains a task queue with priority handling:
// Agent queue structure
{
"agent": "backend-specialist",
"queue": [
{
"task_id": "task-002",
"priority": "high",
"estimated_time": "5m",
"position": 1
},
{
"task_id": "task-008",
"priority": "medium",
"estimated_time": "3m",
"position": 2
}
],
"current_task": "task-001",
"capacity": 2
}
Different project types use optimized distribution patterns:
{
"strategy": "full-stack-web",
"phases": [
{
"name": "foundation",
"agents": ["database", "backend"],
"parallel": true
},
{
"name": "development",
"agents": ["frontend", "backend", "database"],
"parallel": true
},
{
"name": "integration",
"agents": ["testing", "devops"],
"parallel": false
}
]
}
{
"strategy": "api-service",
"phases": [
{
"name": "design",
"agents": ["backend", "database"],
"parallel": true
},
{
"name": "implementation",
"agents": ["backend"],
"parallel": false
},
{
"name": "testing",
"agents": ["testing"],
"parallel": false
}
]
}
{
"strategy": "mobile-app",
"phases": [
{
"name": "setup",
"agents": ["mobile", "backend"],
"parallel": true
},
{
"name": "development",
"agents": ["mobile", "backend", "database"],
"parallel": true
},
{
"name": "testing",
"agents": ["testing"],
"parallel": false
}
]
}
Agents share a common context to avoid redundant work:
{
"shared_context": {
"project_config": {
"name": "ecommerce-app",
"tech_stack": ["react", "nodejs", "postgresql"],
"requirements": ["authentication", "payments", "inventory"]
},
"decisions": {
"styling": "tailwindcss",
"state_management": "zustand",
"testing": "jest"
},
"progress": {
"completed_tasks": ["task-001", "task-002"],
"current_phase": "development"
}
}
}
Agents update shared context as they complete tasks:
// Context update from frontend agent
{
"agent": "frontend-specialist",
"update": {
"components_created": ["Header", "ProductCard", "ShoppingCart"],
"routes_defined": ["/", "/products", "/cart", "/checkout"],
"api_integration_points": [
{ "endpoint": "/api/products", "method": "GET" },
{ "endpoint": "/api/cart", "method": "POST" }
]
}
}
Token budgets are allocated across agents based on task complexity:
{
"token_budget": 100000,
"distribution": {
"frontend-specialist": 30000,
"backend-specialist": 25000,
"database-specialist": 15000,
"testing-specialist": 15000,
"devops-specialist": 10000,
"research-agent": 5000
}
}
The system learns from past executions to optimize future distributions:
{
"learning_metrics": {
"task_completion_times": {
"frontend-component": { "avg": "3m", "std": "1m" },
"api-endpoint": { "avg": "4m", "std": "1.5m" },
"database-schema": { "avg": "5m", "std": "2m" }
},
"agent_performance": {
"frontend-specialist": { "success_rate": 0.96, "avg_quality": 9.2 },
"backend-specialist": { "success_rate": 0.94, "avg_quality": 8.8 }
}
}
}
Track distribution performance in real-time:
{
"current_metrics": {
"active_agents": 3,
"queued_tasks": 5,
"completed_tasks": 12,
"average_task_time": "4.2m",
"token_usage": {
"used": 45000,
"remaining": 55000,
"efficiency": 0.89
}
}
}
{
"analytics": {
"task_distribution": {
"frontend": 35,
"backend": 30,
"database": 15,
"testing": 12,
"devops": 8
},
"parallel_efficiency": 0.78,
"dependency_bottlenecks": ["database-schema", "api-design"],
"agent_utilization": {
"frontend-specialist": 0.85,
"backend-specialist": 0.92,
"database-specialist": 0.67
}
}
}
When tasks fail, the system implements recovery strategies:
{
"failure_handling": {
"retry_strategy": "exponential_backoff",
"max_retries": 3,
"alternative_agents": true,
"fallback_modes": ["simplified", "manual_intervention"]
}
}
If an agent becomes unresponsive:
- Detection: Monitor agent health and response times
- Isolation: Remove agent from active pool
- Redistribution: Reassign pending tasks
- Recovery: Attempt to restart agent
- Fallback: Use backup agents if available
{
"distribution": {
"strategy": "adaptive",
"max_concurrent_agents": 5,
"task_timeout": 300,
"retry_attempts": 2,
"load_balancing": "weighted",
"priority_boost": true,
"context_sharing": true
}
}
{
"custom_rules": [
{
"condition": "task_type == 'security'",
"action": "assign_to_security_specialist",
"priority": "critical"
},
{
"condition": "project_size > 'large'",
"action": "increase_agent_pool",
"params": { "max_agents": 8 }
},
{
"condition": "token_usage > 0.8",
"action": "optimize_tasks",
"params": { "compression": true }
}
]
}
- Clear Requirements: Provide detailed project specifications
- Appropriate Sizing: Match agent pool to project complexity
- Dependency Planning: Design tasks to minimize bottlenecks
- Monitor Progress: Use real-time dashboard
- Adjust Dynamically: Respond to performance metrics
Sequential phases with clear handoffs:
Database Design β API Development β Frontend β Testing β Deployment
Independent workstreams:
Frontend β₯ Backend β₯ Database β₯ Testing
Repeating development cycles:
Cycle 1: [Design β Develop β Test]
Cycle 2: [Design β Develop β Test]
Cycle 3: [Design β Develop β Test]
- Agent Bottlenecks: Some agents overloaded while others idle
- Dependency Deadlocks: Circular dependencies preventing progress
- Resource Exhaustion: Running out of tokens or time
- Communication Failures: Agents not sharing context properly
# View current task distribution
npm run distribution:status
# Analyze bottlenecks
npm run distribution:analyze
# Rebalance agent workload
npm run distribution:rebalance
# Force task reassignment
npm run task:reassign <task-id> <new-agent>
For more information, see Agent System, Performance Tuning, or Configuration.
Support
- Discord: @vibecodingwithphil
- GitHub: @VibeCodingWithPhil