Files
crewAI/tests/test_custom_execution_image_integration.py
Devin AI 229bbd9bbe 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>
2025-06-02 18:18:14 +00:00

37 lines
1019 B
Python

import pytest
from unittest.mock import patch, MagicMock
from crewai import Agent, Task, Crew
@patch('crewai_tools.CodeInterpreterTool')
def test_crew_with_custom_execution_image_integration(mock_code_interpreter_class):
"""Integration test for custom execution image in a Crew workflow."""
mock_tool_instance = MagicMock()
mock_code_interpreter_class.return_value = mock_tool_instance
agent = Agent(
role="Python Developer",
goal="Execute Python code",
backstory="Expert in Python programming",
allow_code_execution=True,
execution_image="python:3.11-slim"
)
task = Task(
description="Calculate 2 + 2",
expected_output="The result of 2 + 2",
agent=agent
)
crew = Crew(
agents=[agent],
tasks=[task]
)
tools = crew._prepare_tools(task, agent)
mock_code_interpreter_class.assert_called_with(
unsafe_mode=False,
default_image_tag="python:3.11-slim"
)