Skip to content

feat(smolagents-daytona): smolagents DaytonaExecutor - #58

Open
mislavivanda wants to merge 5 commits into
mainfrom
feat/smolagents-daytona
Open

feat(smolagents-daytona): smolagents DaytonaExecutor#58
mislavivanda wants to merge 5 commits into
mainfrom
feat/smolagents-daytona

Conversation

@mislavivanda

@mislavivanda mislavivanda commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Summary by cubic

Adds the smolagents-daytona package, a Daytona sandbox executor for smolagents CodeAgents. Installing it registers the daytona executor type via entry point, so CodeAgent(executor_type="daytona") runs generated code in an isolated, stateful sandbox.

Bug fixes

  • The executor inherits the upstream install_packages fix that puts user-site before system site-packages, so the earlier local override was dropped.

CI and release

  • Adds lint, unit, and live integration test jobs; the live E2E test drives the documented CodeAgent context-manager usage and asserts sys.path ordering in a real sandbox.
  • Registers the package for release-please and updates the README table.
  • Until smolagents>=1.27.0 ships, CI installs smolagents from a specific commit and uses --no-deps.

Written for commit f460970. Summary will update on new commits.

Review in cubic

Signed-off-by: Mislav Ivanda <mislavivanda454@gmail.com>
@mislavivanda
mislavivanda requested a review from a team as a code owner September 10, 2026 13:55
@mislavivanda
mislavivanda deployed to integration-tests September 10, 2026 13:56 — with GitHub Actions Active

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 15 files

Heads up: you’re close to your included review allowance. Set a flex budget so reviews don’t pause.

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread packages/smolagents-daytona/README.md
Comment thread packages/smolagents-daytona/tests/integration_tests/test_live_executor.py Outdated
Comment thread packages/smolagents-daytona/tests/unit_tests/test_executor.py
…nager

Exercises the exact usage the README documents: CodeAgent.__exit__ calls
cleanup(), which releases the sandbox. Also simpler than the previous
try/finally form. Addresses review feedback on PR #58.

Signed-off-by: Mislav Ivanda <mislavivanda454@gmail.com>
…the live interpreter

Daytona sandboxes run Python with a non-writable system site-packages, so
pip install silently falls back to a user-site install while exiting 0. The
long-running interpreter context started before that directory existed, so
it is missing from sys.path: the install reports success but the package is
not importable.

Override install_packages to run a plain pip install and then repair
user-site visibility in the live context (sys.path append +
importlib.invalidate_caches). pip already behaves correctly across
virtualenv, writable, and non-writable environments; only the visibility
gap needs fixing.

The live test fixture now also installs a package that is never
preinstalled in sandbox base images (emoji), so the suite genuinely
validates installation instead of passing on preinstalled numpy. Uncovered
by review feedback on PR #58.

The same repair is proposed upstream as the RemotePythonExecutor default
(huggingface/smolagents#2724); this override is removable once that lands.

Signed-off-by: Mislav Ivanda <mislavivanda454@gmail.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 3 files (changes from recent commits).

Heads up: you’re close to your included review allowance. Set a flex budget so reviews don’t pause.

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread packages/smolagents-daytona/smolagents_daytona/_executor.py Outdated
Appending the user-site directory to sys.path left preinstalled copies of a
package earlier on the path, so an agent-requested version installed into
user site could be silently shadowed by an older copy baked into the image.

Insert user site before the first system site-packages entry instead,
mirroring interpreter-startup ordering (site.py does the same), so
agent-requested versions win. Adds a live test asserting the resulting
sys.path ordering in a real sandbox. Addresses review feedback on PR #58.

Signed-off-by: Mislav Ivanda <mislavivanda454@gmail.com>
aprojic
aprojic previously approved these changes Sep 11, 2026
…ided upstream

huggingface/smolagents#2724 (5d49484) adopted the user-site visibility
repair with startup-like ordering as the RemotePythonExecutor default,
matching the implementation this package carried. The override is now
redundant: DaytonaExecutor inherits the fixed default.

The executor is down to its final shape: the FINAL_ANSWER_EXCEPTION_BASE
knob plus __init__, run_code_raise_errors, and cleanup, with no overrides
of base behavior. The live tests that exposed the original issue (install
of a package absent from the base image, sys.path ordering assertion) stay
in place, now validating the inherited default against real sandboxes.

Also bumps the pinned smolagents SHA in CI to the fixed head.

Signed-off-by: Mislav Ivanda <mislavivanda454@gmail.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/smolagents-daytona/tests/unit_tests/test_executor.py">

<violation number="1" location="packages/smolagents-daytona/tests/unit_tests/test_executor.py:171">
P3: This delta drops the local `install_packages` override and makes the test assert on the exact private implementation of the inherited smolagents base-class method, hard-coupling the unit test to upstream internals (`"site.getusersitepackages()"`, `"sys.path.insert"`, `"getsitepackages"`, `"importlib.invalidate_caches()"`, and `not "sys.path.append"`). The upstream base-class default is still being actively refined (the correct snippet is being sent to huggingface/smolagents#2724 per the PR discussion), so a benign upstream refactor to a different but equally valid mechanism (e.g. `site.addusersitepackages()` or a named helper) will break CI even though the runtime behavior stays correct. Prefer asserting the observable contract (installed packages importable, order of `user_site` vs system site on `sys.path`) over matching the generated source text.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

sent_code = executor.run_code_raise_errors.call_args.args[0]
assert "class FinalAnswerException(Exception):" in sent_code

def test_inherited_install_packages_repairs_user_site_visibility(self):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: This delta drops the local install_packages override and makes the test assert on the exact private implementation of the inherited smolagents base-class method, hard-coupling the unit test to upstream internals ("site.getusersitepackages()", "sys.path.insert", "getsitepackages", "importlib.invalidate_caches()", and not "sys.path.append"). The upstream base-class default is still being actively refined (the correct snippet is being sent to huggingface/smolagents#2724 per the PR discussion), so a benign upstream refactor to a different but equally valid mechanism (e.g. site.addusersitepackages() or a named helper) will break CI even though the runtime behavior stays correct. Prefer asserting the observable contract (installed packages importable, order of user_site vs system site on sys.path) over matching the generated source text.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/smolagents-daytona/tests/unit_tests/test_executor.py, line 171:

<comment>This delta drops the local `install_packages` override and makes the test assert on the exact private implementation of the inherited smolagents base-class method, hard-coupling the unit test to upstream internals (`"site.getusersitepackages()"`, `"sys.path.insert"`, `"getsitepackages"`, `"importlib.invalidate_caches()"`, and `not "sys.path.append"`). The upstream base-class default is still being actively refined (the correct snippet is being sent to huggingface/smolagents#2724 per the PR discussion), so a benign upstream refactor to a different but equally valid mechanism (e.g. `site.addusersitepackages()` or a named helper) will break CI even though the runtime behavior stays correct. Prefer asserting the observable contract (installed packages importable, order of `user_site` vs system site on `sys.path`) over matching the generated source text.</comment>

<file context>
@@ -168,13 +168,15 @@ def test_final_answer_exception_base_renders_exception_subclass(self):
 
-    def test_install_packages_repairs_user_site_visibility(self):
-        """Packages must be importable by the live interpreter, not just pip-installed.
+    def test_inherited_install_packages_repairs_user_site_visibility(self):
+        """The inherited smolagents default must keep user-site packages importable.
 
</file context>

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