Architecture: Session 178: Should SandboxProviderFactory have runtime fall...

Documentation for Sessions

🏗️ Architecture: Session 178: Should SandboxProviderFactory have runtime fall...

Date: 2026-03-05
Time: 17:38:08 UTC
Session: gspace1-178.13
Agent: architecture
Confidence: 92%
Status: ✅ Documented


📋 Decision Context

Question:

Session 178: Should SandboxProviderFactory have runtime fallback from SelfHosted to E2B?

Task: Not specified


🎯 Decision Made

Chosen:

Current design selects provider ONCE at startup (onModuleInit). No runtime fallback exists — if self-hosted fails mid-session, the session fails. This is a known gap that should be addressed. Recommended design: add a getProviderWithFallback() method that catches self-hosted errors on getOrCreateSandbox and falls through to E2B, then Playwright. For action-level errors (key/click/type), retry on the SAME provider since those are transient SSH failures, not provider-level issues.

Options Considered:


💭 Reasoning

Provider selection at startup is correct for the primary path — self-hosted is faster and cheaper. But mid-session failures (server restart, network blip, VM crash) should degrade gracefully. Two levels: (1) Provider-level fallback: if POST /sandboxes fails 3x, try E2B. (2) Action-level retry: if POST /sandboxes/:id/key fails, retry 2x with backoff (SSH connection may have dropped). The postWithRetry in SelfHostedProvider already handles action retries (2 attempts). The missing piece is provider-level fallback on session creation failure. Not implementing now per user request (continue testing faster), but documenting as required future work.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation