Skip to content

Comments

feat: add Daytona sandbox support#36

Merged
alexzhang13 merged 7 commits intoalexzhang13:mainfrom
lakshyaag:lakshya/add-daytona-sandboxes
Jan 23, 2026
Merged

feat: add Daytona sandbox support#36
alexzhang13 merged 7 commits intoalexzhang13:mainfrom
lakshyaag:lakshya/add-daytona-sandboxes

Conversation

@lakshyaag
Copy link
Contributor

@lakshyaag lakshyaag commented Jan 6, 2026

Summary

Daytona

Add a new DaytonaREPL environment that runs Python code in Daytona sandboxes, following the same HTTP broker pattern as ModalREPL.

Changes

  • rlm/environments/daytona_repl.py: Full DaytonaREPL implementation using HTTP broker pattern
  • examples/daytona_repl_example.py: Example demonstrating basic code execution and LLM queries
  • rlm/environments/__init__.py: Register "daytona" environment
  • rlm/core/types.py: Add "daytona" to EnvironmentType
  • pyproject.toml: Add daytona optional dependency
  • examples/quickstart.py: Update to use Daytona environment by default

Key Implementation Details

  • Uses daytona SDK for sandbox management
  • Runs Flask broker on port 8080 inside the sandbox
  • Uses Daytona preview URLs (sandbox.get_preview_link) for host-to-sandbox communication
  • Supports llm_query(), llm_query_batched(), and FINAL_VAR()
  • State persistence across code executions via dill serialization

Usage

# Install with daytona support
uv pip install -e ".[daytona]"
# Set API key
export DAYTONA_API_KEY=your_key
# Run example
python -m examples.daytona_repl_example

Example output

============================================================
Daytona REPL Example
============================================================

[1] Basic code execution (no LLM handler)
----------------------------------------
Daytona sandbox started with ID: 1e431a46-e584-432e-b64f-084878ab49e4
Executed: x = 1 + 2
Locals: {'x': '3'}
Executed: print(x * 2)
Stdout: 6
FINAL_VAR('answer'): 42

[2] Code execution with LLM handler
----------------------------------------
LM Handler started at ('127.0.0.1', 34369)
Daytona sandbox started with ID: af6c170a-058c-4c7f-807b-b08299ffd31b
Broker URL: https://8080-af6c170a-058c-4c7f-807b-b08299ffd31b.proxy.daytona.works
Executed: response = llm_query('What is 2+2?')
Response: Mock response to: What is 2+2?

Executed: responses = llm_query_batched([...])
Result: Got 3 responses
First response: Mock response to: Question 1

============================================================
Done!
============================================================

Test Plan

  • Basic code execution works
  • State persistence works across calls
  • FINAL_VAR() extracts variables correctly
  • LLM handler integration works (single and batched queries)
  • Broker communication works over Daytona preview URLs
  • Ruff passes all checks

- Introduced a new Daytona REPL environment for executing Python code in Daytona sandboxes.
- Updated `pyproject.toml` to include `daytona` as an optional dependency.
- Added example usage of Daytona REPL in `examples/daytona_repl_example.py`.
- Modified existing code to support the new `daytona` environment in `rlm/environments/__init__.py` and `rlm/core/types.py`.
- Enhanced the `RLM` initialization in `examples/quickstart.py` to utilize the Daytona environment.

This implementation allows users to run code in isolated Daytona sandboxes, facilitating LLM queries and state management.
@lakshyaag lakshyaag changed the title feat: add Daytona REPL environment support feat: add Daytona sandbox support Jan 6, 2026
@lakshyaag lakshyaag marked this pull request as ready for review January 6, 2026 23:05
@kmad
Copy link
Contributor

kmad commented Jan 8, 2026

This is great, thanks. What's the reasoning to change the quickstart to use Daytona by default? My sense is folks who just want to try it out are more likely to just have an OpenAI/ Anthropic key than a specific provider (Daytona, Modal, etc).

Maybe create a separate provider_example.py with a toggle between the various supported providers, including Daytona?

@lakshyaag
Copy link
Contributor Author

You're right. The quickstart change should be reverted. I was using it as a local sanity check, seem to have committed it accidentally.

@alexzhang13
Copy link
Owner

Thanks for this, testing on my end rn.

Copy link
Owner

@alexzhang13 alexzhang13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on my end, thanks

@alexzhang13 alexzhang13 merged commit 6eb5f6b into alexzhang13:main Jan 23, 2026
3 checks passed
ShaneIsley pushed a commit to ShaneIsley/rlm that referenced this pull request Jan 29, 2026
Merged 4 commits from upstream (alexzhang13/rlm):
- fix: ensure docker env uses shared workspace dir (alexzhang13#48)
- fix: resolve type mismatch in usage summary propagation (alexzhang13#55)
- feat: add Daytona sandbox support (alexzhang13#36)
- fix: propagate depth and persistent parameters in DaytonaREPL (alexzhang13#71)

Resolved conflicts in rlm/core/types.py and rlm/environments/__init__.py
to integrate Daytona with our registry-based environment system.

https://claude.ai/code/session_01VU6KvWSCkKinCMxQDXdNxy
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.

3 participants