Skip to content

Make DockerCommandLineCodeExecutor the default for MagenticOne team #6684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 17, 2025

Summary

This PR changes MagenticOne to use DockerCommandLineCodeExecutor by default instead of LocalCommandLineCodeExecutor, addressing security concerns about local code execution.

Changes

Security Enhancement

  • Docker-first approach: MagenticOne now defaults to containerized code execution when Docker is available
  • Graceful fallback: Falls back to local execution with clear warning when Docker is unavailable
  • User guidance: Provides actionable instructions for Docker installation when needed

Implementation Details

  • Added _is_docker_available() function to detect Docker availability
  • Added _create_default_code_executor() function that prioritizes Docker executor
  • Updated deprecation warning to recommend Docker executor
  • Enhanced docstring examples to demonstrate Docker usage patterns

Example Usage

Before (uses local execution by default):

from autogen_ext.teams.magentic_one import MagenticOne
from autogen_ext.models.openai import OpenAIChatCompletionClient

client = OpenAIChatCompletionClient(model="gpt-4o")
m1 = MagenticOne(client=client)  # Uses LocalCommandLineCodeExecutor

After (uses Docker by default when available):

from autogen_ext.teams.magentic_one import MagenticOne
from autogen_ext.models.openai import OpenAIChatCompletionClient

client = OpenAIChatCompletionClient(model="gpt-4o")
m1 = MagenticOne(client=client)  # Uses DockerCommandLineCodeExecutor when Docker is available

Backward Compatibility

  • Existing code that explicitly provides a code_executor parameter continues to work unchanged
  • When Docker is unavailable, the system falls back to local execution with a clear warning
  • No breaking changes to the API

Testing

  • Added comprehensive tests covering Docker availability scenarios
  • Tests validate fallback behavior and warning messages
  • Smoke tests confirm all functionality works as expected

This change aligns with the security-first principle mentioned in the MagenticOne documentation warnings about using containers for isolation.

Fixes #6683.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: husseinmozannar <25182234+husseinmozannar@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] MagenticOne Team uses local code execution by default Make DockerCommandLineCodeExecutor the default for MagenticOne team Jun 17, 2025
@Copilot Copilot AI requested a review from husseinmozannar June 17, 2025 01:04
Copilot finished work on behalf of husseinmozannar June 17, 2025 01:04
@husseinmozannar
Copy link
Contributor

@copilot no the only change should be to python/packages/autogen-ext/src/autogen_ext/teams/magentic_one.py change localcomandline in the warning to dockerexecutor

Copy link
Contributor Author

Copilot AI commented Jun 17, 2025

@copilot no the only change should be to python/packages/autogen-ext/src/autogen_ext/teams/magentic_one.py change localcomandline in the warning to dockerexecutor

...

I've made the minimal change as requested - updated the deprecation warning in magentic_one.py to recommend DockerCommandLineCodeExecutor instead of LocalCommandLineCodeExecutor. The change is in commit c9b1891.

Copilot finished work on behalf of husseinmozannar June 17, 2025 01:45
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.

MagenticOne Team uses local code execution by default
2 participants