Skip to content

Conversation

@rawwerks
Copy link

@rawwerks rawwerks commented Jan 5, 2026

Summary

Adds CloudflareREPL - a new IsolatedEnv implementation that runs Python code in Cloudflare Workers Sandbox containers.

Why Cloudflare Workers Sandbox?

  • Full Linux environment - Unlike Pyodide Workers, Sandbox containers support any Python package
  • Strong isolation - Each sandbox runs in its own container
  • Edge deployment - Low latency from Cloudflare's global network

What's Included

Component Description
rlm/environments/cloudflare_repl.py CloudflareREPL class implementing IsolatedEnv
workers/rlm-sandbox/ Deployable Cloudflare Worker with Sandbox SDK
CLOUDFLARE.md Complete setup and deployment guide
tests/test_cloudflare_repl.py Import tests + optional E2E tests

Self-Hosted Design

Users deploy their own Cloudflare Worker:

cd workers/rlm-sandbox
npm install
npm run deploy

Usage

# Set env var
export RLM_CF_WORKER_URL=https://your-worker.your-subdomain.workers.dev

# Use it
from rlm.environments import get_environment
env = get_environment("cloudflare", {})
result = env.execute_code("import numpy as np\nprint(np.sum([1,2,3]))")

Test Plan

  • Import tests pass (always run)
  • E2E tests pass (opt-in via RLM_CF_WORKER_URL)
  • Follows same testing pattern as ModalREPL
  • 94 tests pass

🤖 Generated with Claude Code

rawwerks and others added 4 commits January 4, 2026 23:10
Adds a new IsolatedEnv implementation that executes Python code in
Cloudflare Workers Sandbox containers via HTTP API.

Key features:
- HTTP-based API (no Python SDK required)
- State persistence via JSON serialization
- LLM broker polling support
- Per-sandbox session isolation

Files:
- rlm/environments/cloudflare_repl.py: CloudflareREPL implementation
- rlm/environments/__init__.py: Added "cloudflare" to get_environment()
- tests/test_cloudflare_repl.py: Unit tests with mocked HTTP responses

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds documentation and Cloudflare Worker for CloudflareREPL:

- CLOUDFLARE.md: Setup guide with prerequisites, deployment steps,
  usage examples, and API reference
- workers/rlm-sandbox/: Cloudflare Worker implementing sandbox endpoints
  - POST /sandbox/exec - Execute commands
  - POST /sandbox/write - Write files
  - GET /sandbox/read - Read files

Worker deployed and tested at:
https://rlm-sandbox.rawwerks.workers.dev

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace heavy mock tests with simple import tests
- Add optional e2e tests (skip when RLM_CF_WORKER_URL not set)
- Add cloudflare_repl_import to test_imports.py

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- RLM_CF_WORKER_URL: Default worker URL if not passed
- RLM_CF_AUTH_TOKEN: Default auth token if not passed
- Updated CLOUDFLARE.md with env var documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@alexzhang13 alexzhang13 self-requested a review January 8, 2026 20:46
@alexzhang13
Copy link
Owner

I will get to this later, I just don't have a Cloudflare sandbox to test this on yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants