Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

docs(eve): sandbox - report failed analysis commands (#3115)

Andrew Barba0046b8af6c97
diff --git a/docs/sandbox.mdx b/docs/sandbox.mdx
index e1875cbdc..88de347a5 100644
--- a/docs/sandbox.mdx
+++ b/docs/sandbox.mdx
@@ -31,6 +31,11 @@ export default defineTool({
const sandbox = await ctx.getSandbox();
await sandbox.writeTextFile({ path: "analysis/run.py", content: script });
const result = await sandbox.run({ command: "python analysis/run.py" });
+ if (result.exitCode !== 0) {
+ throw new Error(
+ `Analysis failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`,
+ );
+ }
return { stdout: result.stdout };
},
});
@@ -38,13 +43,15 @@ export default defineTool({
`ctx.getSandbox()` takes no arguments, is async, and only works inside authored runtime execution.
+`sandbox.run()` resolves with `{ exitCode, stdout, stderr }` when the process exits, including a nonzero exit. Check `exitCode` before reporting success or using generated files. Throw from a tool to report a failed operation to the model, and throw from `bootstrap` to prevent eve from caching an incomplete setup. The built-in `bash` tool returns all three fields so the model can interpret command results itself.
+
`/workspace` is one namespace across every backend, so `/workspace/foo` points at the same file whether the backend is local or Vercel. When you need to interpolate a path into a generated command, `sandbox.resolvePath("repo/build.py")` anchors a relative path to its absolute `/workspace/repo/build.py` form.
The handle does more than `run` and `writeTextFile`. In every method, relative paths resolve from `/workspace` and absolute paths pass through untouched:
| Method | Does |
| ---------------------------------------- | ----------------------------------------------------------------------------------------------- |
-| `run({ command })` | run one command, block until it exits, return `{ stdout, stderr, ... }` |
+| `run({ command })` | run one command, block until it exits, return `{ exitCode, stdout, stderr }` |
| `spawn(options)` | launch a long-running process (server, watcher) and return a `SandboxProcess` handle |
| `readTextFile` / `writeTextFile` | read/write a UTF-8 (or specified encoding) file; `readTextFile` supports 1-based line ranges |
| `readBinaryFile` / `writeBinaryFile` | read/write raw bytes (images, archives, anything non-text) |
@@ -106,7 +113,12 @@ export default defineSandbox({
revalidationKey: () => "repo-bootstrap-v1",
async bootstrap({ use }) {
const sandbox = await use();
- await sandbox.run({ command: "sudo apt-get install -y jq" });
+ const result = await sandbox.run({ command: "sudo apt-get install -y jq" });
+ if (result.exitCode !== 0) {
+ throw new Error(
+ `Sandbox setup failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`,
+ );
+ }
},
async onSession({ use }) {
await use({ networkPolicy: "deny-all" });
diff --git a/docs/tutorial/run-analysis.mdx b/docs/tutorial/run-analysis.mdx
index 168d832c2..734269ea9 100644
--- a/docs/tutorial/run-analysis.mdx
+++ b/docs/tutorial/run-analysis.mdx
@@ -101,9 +101,14 @@ export default defineTool({
].join("\n"),
});
const root = sandbox.resolvePath("analysis");
- await sandbox.run({
+ const result = await sandbox.run({
command: `cd ${JSON.stringify(root)} && /workspace/.venv/bin/python plot.py`,
});
+ if (result.exitCode !== 0) {
+ throw new Error(
+ `Chart generation failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`,
+ );
+ }
return { chart: `${root}/chart.png` };
},
});
@@ -111,6 +116,8 @@ export default defineTool({
The tool uses the Python environment installed in bootstrap. `matplotlib.use('Agg')` selects a renderer that writes PNGs without a desktop display.
+`sandbox.run()` returns an exit code even when the command fails. Check `exitCode` before returning a chart path. Throwing an error gives the model the failed command's output, including a missing Python executable or matplotlib import, so it can report the failure instead of claiming a chart exists.
+
Now ask for something past plain SQL. If you skipped Step 4, this still works against the Step 3 sample dataset:
```text