huggingface/smolagents · error · Exception

Managed agents are not yet supported with remote code execut

Error message

Managed agents are not yet supported with remote code execution.

What it means

When CodeAgent uses a remote code executor (e2b, modal, docker, blaxel), create_python_executor refuses to proceed if the agent has managed agents attached. Managed agents are registered as locally-callable tools, and there is no mechanism yet to invoke them from a remote sandbox, so the combination raises a plain Exception during construction.

Source

Thrown at src/smolagents/agents.py:1609

        self.cleanup()

    def cleanup(self):
        """Clean up resources used by the agent, such as the remote Python executor."""
        if hasattr(self.python_executor, "cleanup"):
            self.python_executor.cleanup()

    def create_python_executor(self) -> PythonExecutor:
        if self.executor_type not in {"local", "blaxel", "e2b", "modal", "docker"}:
            raise ValueError(f"Unsupported executor type: {self.executor_type}")

        if self.executor_type == "local":
            return LocalPythonExecutor(
                self.additional_authorized_imports,
                **{"max_print_outputs_length": self.max_print_outputs_length} | self.executor_kwargs,
            )
        else:
            if self.managed_agents:
                raise Exception("Managed agents are not yet supported with remote code execution.")
            remote_executors = {
                "blaxel": BlaxelExecutor,
                "e2b": E2BExecutor,
                "docker": DockerExecutor,
                "modal": ModalExecutor,
            }
            return remote_executors[self.executor_type](
                self.additional_authorized_imports, self.logger, **self.executor_kwargs
            )

    def initialize_system_prompt(self) -> str:
        system_prompt = populate_template(
            self.prompt_templates["system_prompt"],
            variables={
                "tools": self.tools,
                "managed_agents": self.managed_agents,
                "authorized_imports": (
                    "You can import from any package you want."

View on GitHub (pinned to 30bb116109)

Solutions

  1. Keep executor_type='local' when using managed agents.
  2. Or drop managed_agents and expose their functionality as regular @tool functions callable from the remote sandbox.
  3. Track smolagents releases for managed-agent support under remote executors and upgrade when available.

Example fix

# before
manager = CodeAgent(model=model, tools=[], managed_agents=[web_agent], executor_type='e2b')

# after
manager = CodeAgent(model=model, tools=[], managed_agents=[web_agent], executor_type='local')
Defensive patterns

Strategy: validation

Validate before calling

REMOTE_EXECUTORS = {'blaxel', 'e2b', 'docker', 'modal'}
if executor_type in REMOTE_EXECUTORS:
    assert not managed_agents, 'managed agents require executor_type="local"'

Prevention

When it happens

Trigger: Building a CodeAgent (or manager agent) with a non-empty managed_agents list and executor_type in {'e2b','modal','docker','blaxel'}; commonly via MultiStepAgent setup where manager CodeAgent delegates to managed agents.

Common situations: Scaling a local multi-agent smolagents setup to E2B/Docker for safety; upgrading configs where remote execution plus managed agents previously seemed to work.

Related errors


AI-assisted analysis of huggingface/smolagents@30bb116109 (2026-08-28). Data as JSON: /api/errors/ec682352acfe3a18. Report an issue: GitHub.