e2b-dev / E2B

Secure open source cloud runtime for AI apps & AI agents
https://e2b.dev/docs
Apache License 2.0
6.94k stars 454 forks source link

Occasional connection issues with the sandbox interpreter #419

Closed Gr3atWh173 closed 2 months ago

Gr3atWh173 commented 2 months ago

Describe the bug We've started seeing elevated rates of "Sandbox not found" exceptions from the past month. Here's the error trace:

SandboxException: Sandbox XXXXXX failed because it cannot be found
  File "threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "e2b/sandbox/sandbox_connection.py", line 439, in _refresh
    raise SandboxException(

To Reproduce A boiled down version of our code:

from e2b_code_interpreter import CodeInterpreter
code_interpreter = CodeInterpreter(api_key="XYZ", cwd=".", timeout=6000)
code_interpreter.notebook.exec_cell("print(1)", timeout=6000)

We're using the e2b-code-interpreter==0.0.3 SDK Expected behavior No "Sandbox not found" exceptions.

Additional context This only happens very occasionally (<5 events per month) and so far we've been unable to track down anything in our code that may be causing this.

ValentaTomas commented 2 months ago

I recommend checking the Beta SDK (https://pypi.org/project/e2b-code-interpreter/0.0.11b10/) which reworked how sandbox connections work.

We have a migration guide here — https://e2b.dev/docs/guide/beta-migration