Skip to content

A programming framework for agentic AI

docs: Add note recommending PythonCodeExecutionTool as an alternative to CodeExecutorAgent (#5809)

Eric Zhu39bfa35e2810
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py
index 6c78ddc01..089daa2a1 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py
@@ -25,6 +25,14 @@ class CodeExecutorAgent(BaseChatAgent, Component[CodeExecutorAgentConfig]):
It is typically used within a team with another agent that generates code snippets to be executed.
+ .. note::
+
+ Consider :class:`~autogen_ext.tools.code_execution.PythonCodeExecutionTool`
+ as an alternative to this agent. The tool allows for executing Python code
+ within a single agent, rather than sending it to a separate agent for execution.
+ However, the model for the agent will have to generate properly escaped code
+ string as a parameter to the tool.
+
Args:
name: The name of the agent.
code_executor: The CodeExecutor responsible for executing code received in messages (:py:class:`~autogen_ext.code_executors.docker.DockerCommandLineCodeExecutor` recommended. See example below)