Skip to content

feat(tools): add BoxLite sandbox tools#6461

Open
DorianZheng wants to merge 1 commit into
crewAIInc:mainfrom
DorianZheng:feat/boxlite-sandbox-tool
Open

feat(tools): add BoxLite sandbox tools#6461
DorianZheng wants to merge 1 commit into
crewAIInc:mainfrom
DorianZheng:feat/boxlite-sandbox-tool

Conversation

@DorianZheng

Copy link
Copy Markdown

Summary

Adds a BoxLite sandbox toolkit — BoxLiteExecTool, BoxLitePythonTool, and BoxLiteFileTool — mirroring the existing E2B and Daytona sandbox tools. BoxLite boots an OCI image inside a hardware-isolated micro-VM on the local host, so unlike E2B and Daytona it needs no API key or cloud account. It gives agents a self-hosted, VM-strength isolation boundary for running model-generated code.

Tools

  • BoxLiteExecTool — run a shell command → {exit_code, stdout, stderr}
  • BoxLitePythonTool — run Python (python3) → {exit_code, stdout, stderr}
  • BoxLiteFileTool — read / write / append / list / delete / mkdir / info / exists

All three share BoxLiteBaseTool's lifecycle — ephemeral (default; fresh box per call) or persistent (one cached box, removed at process exit) — matching the E2B/Daytona base.

Notes

  • Optional dependency: pip install "crewai-tools[boxlite]" (installs boxlite[sync]).
  • Requires a micro-VM host: macOS 12+ (Apple Silicon) or Linux with KVM (/dev/kvm).
  • Local only: no remote/attach-by-id mode, since BoxLite's synchronous API does not expose one with the rich exec (cwd/env/timeout) these tools use.
  • Text results only: no Jupyter kernel, so no rich results (charts/dataframes) — just stdout/stderr/exit code.
  • Files over shell: BoxLiteFileTool runs filesystem ops via the box shell (content transferred as base64), since BoxLite exposes command execution rather than a files API.

Verification

  • ruff check / ruff format clean; mypy (strict) passes.
  • tool.specs.json regenerated to include the three tools.
  • Exercised end-to-end against a real micro-VM (boxlite 0.9.7, macOS/arm64): Python 6*7 → 42, stderr + non-zero-exit capture, exec exit-code propagation, a file read/write/append/list/exists/delete round-trip, and a 256-byte binary round-trip — all pass.

No tests are added, matching the existing E2B and Daytona sandbox tools (their execution needs live infra that CI can't provide).

https://claude.ai/code/session_01CifaVdyjdFaCpCqbtDduyY

Add BoxLiteExecTool, BoxLitePythonTool, and BoxLiteFileTool, mirroring the
existing E2B and Daytona sandbox tools. BoxLite runs an OCI image inside a
hardware-isolated micro-VM on the local host, so it needs no API key or cloud
account -- a self-hosted option for agent-driven code execution.

Registers the tools in crewai_tools, adds the `boxlite` optional dependency,
and regenerates tool.specs.json.

Claude-Session: https://claude.ai/code/session_01CifaVdyjdFaCpCqbtDduyY
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds BoxLite sandbox tools to crewai-tools: BoxLiteExecTool, BoxLiteFileTool, and BoxLitePythonTool, backed by a shared BoxLiteBaseTool that manages micro-VM lifecycle (ephemeral or persistent). Includes new optional dependency, package exports, tool specs, and README documentation.

Changes

BoxLite Sandbox Tool Integration

Layer / File(s) Summary
BoxLite optional dependency
lib/crewai-tools/pyproject.toml
Adds a boxlite optional dependency group requiring boxlite[sync]>=0.8.2,<1.0.
Shared box lifecycle management
lib/crewai-tools/src/crewai_tools/tools/boxlite_sandbox_tool/boxlite_base_tool.py
Adds BoxLiteBaseTool with config fields (image, cpus, memory_mib, persistent), lazy import of the optional boxlite package, box creation/acquisition/release logic for ephemeral vs. persistent modes, atexit-registered cleanup, close(), and a result-normalization helper.
Shell execution tool
lib/crewai-tools/src/crewai_tools/tools/boxlite_sandbox_tool/boxlite_exec_tool.py
Adds BoxLiteExecToolSchema and BoxLiteExecTool, which run shell commands inside an acquired box with envs, cwd, and timeout, returning normalized exit code/stdout/stderr.
Filesystem operations tool
lib/crewai-tools/src/crewai_tools/tools/boxlite_sandbox_tool/boxlite_file_tool.py
Adds BoxLiteFileToolSchema and BoxLiteFileTool supporting read/write/append/list/delete/mkdir/info/exists actions via internal shell-based helpers, with text and base64 binary handling.
Python execution tool
lib/crewai-tools/src/crewai_tools/tools/boxlite_sandbox_tool/boxlite_python_tool.py
Adds BoxLitePythonToolSchema and BoxLitePythonTool, executing user Python code inside a box via /bin/sh -c with code passed positionally, forwarding envs/timeout.
Public exports, specs, and docs
lib/crewai-tools/src/crewai_tools/__init__.py, .../tools/__init__.py, .../boxlite_sandbox_tool/__init__.py, lib/crewai-tools/tool.specs.json, .../boxlite_sandbox_tool/README.md
Exports the three BoxLite tools from package __init__ modules, adds tool spec definitions (init/run schemas) to tool.specs.json, and documents installation, host requirements, lifecycle behavior, and usage examples.

Sequence Diagram(s)

sequenceDiagram
  participant ComponentA
  participant ComponentB
  ComponentA->>ComponentB: observable interaction
Loading

Suggested reviewers: greysonlalonde, vinibrsl

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding BoxLite sandbox tools.
Description check ✅ Passed The description is directly related to the BoxLite sandbox tool additions and matches the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
lib/crewai-tools/src/crewai_tools/tools/boxlite_sandbox_tool/boxlite_file_tool.py (1)

117-122: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

File operations can hang: _sh never forwards a timeout.

BoxLiteExecTool and BoxLitePythonTool both accept a timeout, but every file operation routes through _sh, which calls box.exec without one. A slow/stuck command (e.g. cat on a huge file, find on a deep tree) can block the agent indefinitely with no way to bound it. Consider threading an optional timeout through _sh and the schema, mirroring the other two tools.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@lib/crewai-tools/src/crewai_tools/tools/boxlite_sandbox_tool/boxlite_file_tool.py`
around lines 117 - 122, The file-operation path can hang because `_sh` does not
pass any timeout through to `box.exec`, even though `BoxLiteExecTool` and
`BoxLitePythonTool` already support one. Update `_sh` in `BoxLiteFileTool` to
accept an optional timeout and forward it into `box.exec`, then thread that
timeout through the relevant schema/argument plumbing so file commands are
bounded consistently with the other BoxLite tools.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@lib/crewai-tools/src/crewai_tools/tools/boxlite_sandbox_tool/boxlite_file_tool.py`:
- Around line 165-168: The _list method in BoxliteFileTool uses a find
invocation with a leading -- that breaks on BusyBox-based OCI images, so update
the command construction in _list to use a portable form or a safe path-prefix
guard instead. Keep the existing path/depth behavior intact, but remove the
GNU-style -- handling so list continues to work across arbitrary OCI targets,
including Alpine/BusyBox images.

---

Nitpick comments:
In
`@lib/crewai-tools/src/crewai_tools/tools/boxlite_sandbox_tool/boxlite_file_tool.py`:
- Around line 117-122: The file-operation path can hang because `_sh` does not
pass any timeout through to `box.exec`, even though `BoxLiteExecTool` and
`BoxLitePythonTool` already support one. Update `_sh` in `BoxLiteFileTool` to
accept an optional timeout and forward it into `box.exec`, then thread that
timeout through the relevant schema/argument plumbing so file commands are
bounded consistently with the other BoxLite tools.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 16cf0484-6db6-4bfa-aaf5-38963dfbc3e1

📥 Commits

Reviewing files that changed from the base of the PR and between 2b90117 and 53fa95f.

📒 Files selected for processing (10)
  • lib/crewai-tools/pyproject.toml
  • lib/crewai-tools/src/crewai_tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/boxlite_sandbox_tool/README.md
  • lib/crewai-tools/src/crewai_tools/tools/boxlite_sandbox_tool/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/boxlite_sandbox_tool/boxlite_base_tool.py
  • lib/crewai-tools/src/crewai_tools/tools/boxlite_sandbox_tool/boxlite_exec_tool.py
  • lib/crewai-tools/src/crewai_tools/tools/boxlite_sandbox_tool/boxlite_file_tool.py
  • lib/crewai-tools/src/crewai_tools/tools/boxlite_sandbox_tool/boxlite_python_tool.py
  • lib/crewai-tools/tool.specs.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant