#2722·smolagents

Make code executors pluggable via entry points

Author: albertvillanovaCreated Sep 1, 2026Updated Sep 30, 2026
Labelsenhancementstatus:acceptedarea:executorspriority:p1

Problem

Adding a code executor to smolagents currently requires a pull request to the core library. executor_type is a hardcoded Literal, and the executors themselves live in a hardcoded dict:

python
executor_type: Literal["local", "blaxel", "e2b", "modal", "docker"] = "local"
...
remote_executors = {"e2b": E2BExecutor, "docker": DockerExecutor, "modal": ModalExecutor, ...}

There is no entry-point or registry mechanism anywhere in the codebase, so a third party has no way to ship an executor without us merging it. That has two consequences:

  1. Every new sandbox provider arrives as a core pull request, and we become the bottleneck for integrations we did not write and cannot properly test.
  2. Executor integrations in core are covered by mocked tests only. We ship code against hosted services that is never exercised against the real service, while the provider could test it properly.

Proposal

Make executors pluggable, so anyone can publish one as a separate package.

The abstractions for this already mostly exist. PythonExecutor is an ABC with three abstract methods, and RemotePythonExecutor narrows the contract for remote implementations to essentially run_code_raise_errors, with optional install_packages and cleanup. What is missing is exposing that contract as public API and resolving executor_type through it.

Sketch:

  • Document PythonExecutor and RemotePythonExecutor as the public extension contract, with stability guarantees.
  • Resolve executor_type through an entry point group (e.g. smolagents.executors), falling back to the built-ins.
  • Keep passing an executor instance directly via the executor argument as the no-packaging path.
  • Add a test that registers a dummy executor through the mechanism, so the contract is covered.
  • Document how to write and publish an executor.

A third-party package would then do:

toml
[project.entry-points."smolagents.executors"]
myprovider = "smolagents_myprovider:MyProviderExecutor"
python
CodeAgent(model=model, tools=[], executor_type="myprovider")

Why now

We have a pull request open adding another provider (#2147), which has waited far too long for a review. Rather than resolve it case by case, we would prefer to give providers a supported path that does not depend on our review capacity, and that lets them release on their own schedule.

Open questions

  • Naming and stability of the contract. RemotePythonExecutor currently exposes send_tools, send_variables and install_packages alongside run_code_raise_errors. Which of these are part of the public contract, and which are internal?
  • Discovery. Should third-party executors be discoverable and listed anywhere, or is documentation enough?
  • What stays in core. local is the default and clearly belongs. Docker requires no account or hosted service, so it is arguably a primitive too. Whether the hosted providers currently in core should move out over time, and on what timeline, is a separate discussion that this issue does not decide.
  • Error handling parity. Implementations diverge today, for example in how install_packages reports failures. Worth settling as part of documenting the contract.

Feedback welcome, particularly from anyone maintaining an executor against smolagents today.