Skip to content

[Phase 4.B] E2BAgentAdapter: cloud execution in isolated Linux VM #534

Description

@frankbria

Overview

Implement E2BAgentAdapter so that --engine cloud runs the CodeFrame agent inside a full Linux VM via the E2B SDK, enabling long-running, fully isolated execution without touching the local filesystem.

Motivation

Some tasks are too risky or too slow to run on the local filesystem:

  • Tasks that modify many files across the repo
  • Tasks needing specific OS-level dependencies
  • Parallel tasks where each needs a full clean environment
  • CI-grade isolation without spinning up Docker

E2B provides on-demand Linux sandboxes via API with up to 1-hour execution windows.

Deliverables

codeframe/adapters/e2b/adapter.py

class E2BAgentAdapter:
    """Runs CodeFrame's ReAct agent loop inside an E2B sandbox."""
    
    def execute(self, task: Task, context: TaskContext) -> AgentResult:
        # 1. Create E2B sandbox
        # 2. Upload workspace files (with credential scanning — no secrets)
        # 3. Install codeframe in sandbox
        # 4. Run ReactAgent inside sandbox
        # 5. Download changed files
        # 6. Return AgentResult

CLI

  • --engine cloud on cf work start and cf work batch run
  • Requires E2B_API_KEY in environment (validated at startup)

Budget tracking

  • Track E2B sandbox-minutes per task and per batch
  • cf work show <id> displays cloud execution cost
  • Configurable timeout (default: 30 min, max: 60 min)

Credential scanning

  • Before upload, scan for .env, secrets, API keys
  • Refuse upload if credential patterns detected
  • Log what was and wasn't uploaded

ExecutionContext integration

  • IsolationLevel.CLOUD routes through this adapter
  • context.workspace_path points to the downloaded results directory post-execution

Acceptance Criteria

  • E2BAgentAdapter in codeframe/adapters/e2b/adapter.py
  • --engine cloud flag wired in CLI and runtime
  • E2B_API_KEY validated before execution starts
  • Workspace upload with credential scanning
  • Changed files downloaded and applied to local repo
  • Timeout management (configurable, max 60 min)
  • Budget/cost tracked and displayed in cf work show
  • Tests with E2B sandbox mocked

Dependencies

Track

Phase 4.B — Execution Environment Layer

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureSystem architecture and design patternsenhancementNew feature or requestphase-4Phase 4: Multi-Agent Coordinationpriority:medium

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions