Skip to content

feat: add Daytona sandbox backend for code execution#460

Open
mu-hashmi wants to merge 5 commits into
rllm-org:mainfrom
mu-hashmi:feat/daytona-sandbox-backend
Open

feat: add Daytona sandbox backend for code execution#460
mu-hashmi wants to merge 5 commits into
rllm-org:mainfrom
mu-hashmi:feat/daytona-sandbox-backend

Conversation

@mu-hashmi

@mu-hashmi mu-hashmi commented Mar 25, 2026

Copy link
Copy Markdown

fixes #459

Summary

Adds daytona as a new cloud sandbox backend. This uses the daytona package and the daytona.Daytona sdk.

What changed

  • adds rllm/tools/code_tools/daytona_tool.py
  • wires PythonInterpreter(backend="daytona") to the new backend
  • adds daytona to the [code-tools] extra
  • updates the installation docs to mention daytona

Implementation Notes

  • uses sandbox.process.code_run(...) instead of the code interpreter/session path, so execution stays stateless per call and matches current CodeTool usage in rllm
  • passes through the daytona config knobs that matter here: api_url, snapshot, and env_vars
  • retry handling: auth errors fail fast, other errors retry
  • maps successful runs to stdout, and non-zero exits to stderr plus the last traceback line in error

Validation

$ python -m rllm.tools.code_tools.daytona_tool
CodeToolOutput(name='daytona_python',
               output=None,
               error=None,
               metadata=None,
               stdout='Hello, world!\n',
               stderr=None)
CodeToolOutput(name='daytona_python',
               output=None,
               error='ZeroDivisionError: division by zero',
               metadata=None,
               stdout=None,
               stderr='Traceback (most recent call last):\n'
                      '  File "<stdin>", line 1, in <module>\n'
                      'ZeroDivisionError: division by zero\n')

@mu-hashmi mu-hashmi marked this pull request as draft March 31, 2026 00:03

@JiwaniZakir JiwaniZakir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In daytona_tool.py, the retry logic in forward has a subtle issue: when all retries are exhausted, _restart_sandbox is called to create a fresh sandbox, but then an error is immediately returned without attempting to execute code on the new sandbox — so the restart effort is entirely wasted for the current call. The caller receives an error and must retry manually, defeating the purpose of the restart.

The __main__ block's async test is also broken: interpreter(code=..., use_async=True) passes use_async through **kwargs to forward, which never inspects it, so the call returns a CodeToolOutput synchronously rather than a coroutine — await coro will then raise a TypeError. Either forward needs an async def variant or the example should be removed.

Minor: super().__init__() is called after self._init_sandbox() in __init__, which means sandboxes are already allocated before the parent class is fully initialized — if the base CodeTool.__init__ raises, you'd leak sandbox resources. Calling super().__init__() first would be safer.

Signed-off-by: Muhammad Hashmi <muhash@Muhammads-MacBook-Pro-2.local>
@mu-hashmi mu-hashmi force-pushed the feat/daytona-sandbox-backend branch from 4a040ea to 06b20ef Compare April 19, 2026 21:50
Signed-off-by: Muhammad Hashmi <muhash@Muhammads-MacBook-Pro-2.local>
@mu-hashmi mu-hashmi force-pushed the feat/daytona-sandbox-backend branch from 06b20ef to f7a8f8d Compare April 19, 2026 22:11
Muhammad Hashmi added 2 commits April 19, 2026 16:15
Signed-off-by: Muhammad Hashmi <muhash@Muhammads-MacBook-Pro-2.local>
Signed-off-by: Muhammad Hashmi <muhash@Muhammads-MacBook-Pro-2.local>
@mu-hashmi mu-hashmi force-pushed the feat/daytona-sandbox-backend branch from f7a8f8d to 726f8ee Compare April 19, 2026 23:15
@mu-hashmi mu-hashmi marked this pull request as ready for review April 19, 2026 23:41
@mu-hashmi

Copy link
Copy Markdown
Author

@JiwaniZakir updated PR addressing review comments (apologies for letting the PR go stale for this long!)

@mu-hashmi mu-hashmi requested a review from JiwaniZakir April 28, 2026 14:01
@mu-hashmi

Copy link
Copy Markdown
Author

@JiwaniZakir just wanted to gently bump this, updated the PR addressing the issues you brought up. appreciate the review!

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.

Add Daytona as a code execution sandbox backend

2 participants