Overview
Automatically select the best sandbox provider based on task characteristics when no explicit provider is specified.
Selection Criteria
Task Duration
- < 5 minutes: Native/Docker (free, instant)
- 5-30 minutes: Native/Docker or E2B
-
30 minutes: E2B (more reliable for long tasks)
Resource Requirements
- Low CPU/memory: Native
- Medium: Docker
- High/GPU: E2B (dedicated VM)
Network Requirements
- No external access: Native (most secure)
- External APIs: Docker or E2B
- Full network: E2B
User Preference
- Cost-conscious: Native > Docker > E2B
- Speed-focused: E2B (parallel VM)
- Security-focused: Native (OS-level isolation)
Implementation
// src/e2b/providers/auto-select.ts
export interface TaskHints {
estimatedDuration?: number; // minutes
requiresNetwork?: boolean;
requiresGpu?: boolean;
resourceIntensity?: 'low' | 'medium' | 'high';
costSensitive?: boolean;
}
export function selectProvider(
hints: TaskHints,
available: string[]
): string {
// Quick tasks → prefer free providers
if (hints.estimatedDuration && hints.estimatedDuration < 5) {
if (available.includes('native')) return 'native';
if (available.includes('docker')) return 'docker';
}
// Long tasks → prefer E2B for reliability
if (hints.estimatedDuration && hints.estimatedDuration > 30) {
if (available.includes('e2b')) return 'e2b';
}
// Cost-sensitive → prefer free options
if (hints.costSensitive) {
if (available.includes('native')) return 'native';
if (available.includes('docker')) return 'docker';
}
// Default: use E2B if available
if (available.includes('e2b')) return 'e2b';
// Fallback to first available
return available[0] || 'e2b';
}
CLI Integration
# Let parallel-cc decide
parallel-cc sandbox-run --repo . --prompt "Quick fix" --auto-provider
# Provide hints
parallel-cc sandbox-run --repo . --prompt "Long task" \
--estimated-duration 45 \
--cost-sensitive
Files to Create
- `src/e2b/providers/auto-select.ts`
- `tests/e2b/auto-select.test.ts`
Acceptance Criteria
Dependencies
Overview
Automatically select the best sandbox provider based on task characteristics when no explicit provider is specified.
Selection Criteria
Task Duration
Resource Requirements
Network Requirements
User Preference
Implementation
CLI Integration
Files to Create
Acceptance Criteria
Dependencies