feat: add e2b-haystack integration for E2B cloud sandbox tools#3195
Open
feat: add e2b-haystack integration for E2B cloud sandbox tools#3195
Conversation
Introduces `e2b-haystack`, a new integration that provides E2B cloud sandbox tools for Haystack agents. Migrated from deepset-ai/haystack-experimental#448. Exposes four tools sharing a single `E2BSandbox` instance: - `RunBashCommandTool` - execute bash commands - `ReadFileTool` - read sandbox filesystem files - `WriteFileTool` - write sandbox filesystem files - `ListDirectoryTool` - list directory contents Plus `E2BToolset` as a convenience Toolset bundling all four tools. Includes 38 unit tests, two usage examples, and full serialisation round-trip support. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add mypy override to ignore missing stubs for `e2b` package (which doesn't ship a py.typed marker or type stubs) - Quote \$GITHUB_OUTPUT in workflow to fix actionlint/shellcheck SC2086 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Coverage report (e2b)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
Gate the "Run integration tests" CI step on the E2B_API_KEY env var being present, matching the pattern used by other integrations (e.g. cohere). Without this the step exits with code 5 (no tests collected) because there are no integration-marked tests and no API key is configured yet. Also exposes E2B_API_KEY from secrets at the workflow env level so it will be available once a maintainer adds the secret to the repo. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds real end-to-end integration tests (marked @pytest.mark.integration) that exercise all four tools against a live E2B sandbox: - RunBashCommandTool: echo, non-zero exit code, stderr capture - WriteFileTool + ReadFileTool: round-trip, nested directory creation - ListDirectoryTool: list /tmp, list after write - E2BToolset: warm_up/close lifecycle, shared sandbox state across tools Also suppresses S108 (/tmp path warning) in test per-file-ignores — /tmp is correct and intentional inside a sandboxed environment. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The e2b SDK raises CommandExitException (with exit_code/stdout/stderr attributes) instead of returning a result for non-zero exit codes. Detect this via duck-typing and return the formatted result string so the LLM can see and react to the exit status, rather than propagating a ToolInvocationError. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Toolset was introduced in haystack-ai 2.19.0. The previous lower bound of 2.12.0 caused an ImportError on the "lowest direct dependencies" CI run. This matches the floor already used by the mcp integration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
e2b 1.x does not have the Sandbox.create() classmethod — it was introduced in 2.0.0. The lowest-direct-dependency CI job resolves e2b>=1.0.0 to 1.0.0, causing AttributeError when mock.patch tries to patch Sandbox.create. Bumping the floor to >=2.0.0 fixes the lowest- direct run while keeping Python 3.9+ compatibility (e2b 2.x requires >=3.9). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates the E2B sandbox toolset prototype from deepset-ai/haystack-experimental#448 into a proper
e2b-haystackintegration package.E2BSandboxfor managing the lifecycle of an E2B cloud sandbox (lazywarm_up,close, full serialisation round-trip)Toolsubclasses that share a single sandbox instance:RunBashCommandTool,ReadFileTool,WriteFileTool,ListDirectoryToolE2BToolset(aToolsetsubclass) that bundles all four tools as a convenience — just passE2BToolset()to any HaystackAgenthaystack_integrations/tools/module path convention (same asmcp-haystackandgithub-haystack)Test plan
hatch run test:unit) — all sandbox calls are mocked, no API key neededhatch run fmt-check)integrations/e2b/examples/for correctnessE2B_API_KEY)E2B_API_KEYsecret to GitHub repo for CI integration tests🤖 Generated with Claude Code