If you installed crewai-tools[e2b] recently and E2BPythonTool crashes with
AttributeError: 'Sandbox' object has no attribute '_transport'
you are not doing anything wrong. On Python 3.11 and newer, crewai-tools[e2b] installs e2b 2.64 together with e2b-code-interpreter 2.6. The code interpreter 2.6 still expects an attribute that e2b 2.64 removed, so every Python call fails. The shell and file tools keep working, because they don't use the code interpreter.
The fix
Upgrade the code interpreter after installing CrewAI's tools:
pip install "crewai-tools[e2b]"
pip install -U "e2b-code-interpreter>=2.11"
This is outside the version range crewai-tools asks for, so do it in a virtualenv of its own if you also use other E2B tooling. With e2b 2.64 and e2b-code-interpreter 2.11 all three tools work:
from crewai_tools import E2BExecTool, E2BFileTool, E2BPythonTool
print(E2BExecTool().run(command="python3 --version")["stdout"])
print(E2BPythonTool().run(code="print(sum(range(10)))")["stdout"])
files = E2BFileTool(persistent=True)
files.run(action="write", path="/home/user/todo.txt", content="ship it")
print(files.run(action="read", path="/home/user/todo.txt")["content"])
I reported the pin to the CrewAI team: https://github.com/crewAIInc/crewAI/issues/10174
Two things worth knowing about these tools
-
Ephemeral by default.
E2BExecToolandE2BPythonToolcreate a new sandbox for every call. That's safe, but each call pays the start-up time and nothing survives between calls. Passpersistent=Truewhen an agent should keep files or variables. -
The domain is configurable. All three tools take a
domainargument that falls back toE2B_DOMAIN, so they work with self-hosted E2B or any E2B-compatible endpoint.
Disclosure: I run getrollouts.dev, an E2B-compatible sandbox service, which is how I ran into this. The fix above has nothing to do with it and applies to e2b.dev the same way. If you want to try the tools somewhere else: E2B_DOMAIN=getrollouts.dev, 24-hour sessions, no monthly fee. Runnable example: 13_crewai.py.
Top comments (0)