crewai - 💡(How to fix) Fix [FEATURE] Add Wasm-based code interpreter tool to safely run untrusted code. [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
crewAIInc/crewAI#4810Fetched 2026-04-08 00:40:12
View on GitHub
Comments
2
Participants
2
Timeline
7
Reactions
0
Author
Timeline (top)
commented ×2closed ×1cross-referenced ×1labeled ×1

Code Example

from crewai_capsule import CapsulePythonREPLTool

python_tool = CapsulePythonREPLTool()

code = """
def factorial(n):
    if n <= 1:
        return 1
    return n * factorial(n - 1)

factorial(6)
"""

result = python_tool.run(code)
print(result) # "720"
RAW_BUFFERClick to expand / collapse

Feature Area

Integration with external tools

Is your feature request related to a an existing bug? Please link it here.

It's related to the security vulnerabilities identified in the current CodeInterpreterTool (#4516). The discussion suggests more robust isolation like containers or other non Python-level sandboxing, which is what this integration provides with Wasm.

Describe the solution you'd like

I'm proposing an integration called crewai-capsule. It's a pre-configured version of Capsule, a runtime I built to sandbox AI agent tasks using WebAssembly.

Here's an example of how it would work:

from crewai_capsule import CapsulePythonREPLTool

python_tool = CapsulePythonREPLTool()

code = """
def factorial(n):
    if n <= 1:
        return 1
    return n * factorial(n - 1)

factorial(6)
"""

result = python_tool.run(code)
print(result) # "720"

Only the first run takes about a second (cold start), then every next run starts in ~10ms.

Describe alternatives you've considered

No response

Additional context

PyPI package: crewai-capsule Integration repository: github.com/mavdol/crewAI-capsule Main Capsule repository: github.com/mavdol/capsule

I've also built a separate MCP server that provides the same sandboxing capabilities, if that's of interest: github.com/mavdol/capsule/integrations/mcp-server

I'd be happy to submit a PR to integrate this solution into CrewAI (whether through documentation, a direct integration, or any other convenient way).

Willingness to Contribute

Yes, I'd be happy to submit a pull request

extent analysis

Fix Plan

To integrate the crewai-capsule solution, follow these steps:

  • Install the crewai-capsule PyPI package: pip install crewai-capsule
  • Import the CapsulePythonREPLTool class: from crewai_capsule import CapsulePythonREPLTool
  • Create an instance of the CapsulePythonREPLTool class: python_tool = CapsulePythonREPLTool()
  • Run the code using the run method: result = python_tool.run(code)

Example code:

from crewai_capsule import CapsulePythonREPLTool

python_tool = CapsulePythonREPLTool()

code = """
def factorial(n):
    if n <= 1:
        return 1
    return n * factorial(n - 1)

factorial(6)
"""

result = python_tool.run(code)
print(result)  # "720"

Verification

To verify that the fix worked, check the execution time of the code. The first run should take around 1 second (cold start), and subsequent runs should take around 10ms.

Extra Tips

  • Make sure to handle any exceptions that may occur during code execution.
  • Consider adding logging or monitoring to track the performance and security of the crewai-capsule integration.
  • Review the documentation and code of the crewai-capsule package to ensure it meets the security and performance requirements of your application.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING