Add execution_image parameter to Agent for custom Docker images

- Add execution_image field to Agent class for specifying custom Docker images
- Modify get_code_execution_tools() to pass custom image to CodeInterpreterTool
- Add comprehensive tests for the new functionality
- Update documentation with usage examples
- Fixes #2933: Allow customizing CrewAI code executor Docker image

Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
Devin AI
2025-06-02 18:18:14 +00:00
parent c045399d6b
commit 229bbd9bbe
4 changed files with 143 additions and 1 deletions

View File

@@ -92,6 +92,22 @@ programmer_agent = Agent(
)
```
You can also specify a custom Docker image for code execution:
```python Code
from crewai import Agent
# Create an agent with code execution enabled and custom Docker image
programmer_agent = Agent(
role="Python Programmer",
goal="Write and execute Python code to solve problems",
backstory="An expert Python programmer who can write efficient code to solve complex problems.",
allow_code_execution=True, # This automatically adds the CodeInterpreterTool
execution_image="python:3.11-slim", # Custom Docker image with specific Python version
verbose=True,
)
```
### Enabling `unsafe_mode`
```python Code