Spaces:
Running
Running
Commit ·
e5cf3fa
1
Parent(s): c5e7f6c
Return raw dict from sandbox, let harness handle truncation
Browse filesMatches the updated SandboxFunc contract — sandbox returns a dict,
execute_tool applies truncation and serializes.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- sandbox_e2b.py +14 -19
sandbox_e2b.py
CHANGED
|
@@ -2,12 +2,11 @@
|
|
| 2 |
|
| 3 |
from __future__ import annotations
|
| 4 |
|
| 5 |
-
import json
|
| 6 |
from pathlib import Path
|
| 7 |
|
| 8 |
from e2b_code_interpreter import Sandbox
|
| 9 |
|
| 10 |
-
from llm_harness.sandbox import TIMEOUT_SECONDS
|
| 11 |
|
| 12 |
# Reuse a sandbox across tool calls within a session.
|
| 13 |
# The caller manages the lifecycle via create/close.
|
|
@@ -59,7 +58,7 @@ def run_python(
|
|
| 59 |
workspace: Path | None = None,
|
| 60 |
scratch_dir: Path | None = None,
|
| 61 |
timeout: int = TIMEOUT_SECONDS,
|
| 62 |
-
) ->
|
| 63 |
"""Execute Python code in an E2B sandbox. Same interface as sandbox.run_python."""
|
| 64 |
sandbox = get_or_create_sandbox(workspace, scratch_dir)
|
| 65 |
|
|
@@ -81,20 +80,16 @@ def run_python(
|
|
| 81 |
else:
|
| 82 |
exit_code = 0
|
| 83 |
|
| 84 |
-
return
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
}
|
| 91 |
-
)
|
| 92 |
except TimeoutError:
|
| 93 |
-
return
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
}
|
| 100 |
-
)
|
|
|
|
| 2 |
|
| 3 |
from __future__ import annotations
|
| 4 |
|
|
|
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
from e2b_code_interpreter import Sandbox
|
| 8 |
|
| 9 |
+
from llm_harness.sandbox import TIMEOUT_SECONDS
|
| 10 |
|
| 11 |
# Reuse a sandbox across tool calls within a session.
|
| 12 |
# The caller manages the lifecycle via create/close.
|
|
|
|
| 58 |
workspace: Path | None = None,
|
| 59 |
scratch_dir: Path | None = None,
|
| 60 |
timeout: int = TIMEOUT_SECONDS,
|
| 61 |
+
) -> dict:
|
| 62 |
"""Execute Python code in an E2B sandbox. Same interface as sandbox.run_python."""
|
| 63 |
sandbox = get_or_create_sandbox(workspace, scratch_dir)
|
| 64 |
|
|
|
|
| 80 |
else:
|
| 81 |
exit_code = 0
|
| 82 |
|
| 83 |
+
return {
|
| 84 |
+
"stdout": stdout,
|
| 85 |
+
"stderr": stderr,
|
| 86 |
+
"exit_code": exit_code,
|
| 87 |
+
"timed_out": False,
|
| 88 |
+
}
|
|
|
|
|
|
|
| 89 |
except TimeoutError:
|
| 90 |
+
return {
|
| 91 |
+
"stdout": "",
|
| 92 |
+
"stderr": "Execution timed out.",
|
| 93 |
+
"exit_code": -1,
|
| 94 |
+
"timed_out": True,
|
| 95 |
+
}
|
|
|
|
|
|