docs: add note about markdown code block requirement in CodeExecutorA… (#5785)

## Why are these changes needed?

The CodeExecutorAgent documentation needs to be updated to explicitly
mention that it only processes code properly formatted in markdown code
blocks with triple backticks. This change adds a clear note with
examples to help users understand the required format for code
execution.

## Related issue number

Closes #5771


Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
This commit is contained in:
Jay Prakash Thakur 2025-03-02 17:00:08 -08:00 committed by GitHub
parent b8b13935c9
commit 78ff883d24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,6 +37,23 @@ class CodeExecutorAgent(BaseChatAgent, Component[CodeExecutorAgentConfig]):
It is recommended that the `CodeExecutorAgent` agent uses a Docker container to execute code. This ensures that model-generated code is executed in an isolated environment. To use Docker, your environment must have Docker installed and running.
Follow the installation instructions for `Docker <https://docs.docker.com/get-docker/>`_.
.. note::
The code executor only processes code that is properly formatted in markdown code blocks using triple backticks.
For example:
.. code-block:: text
```python
print("Hello World")
```
# or
```sh
echo "Hello World"
```
In this example, we show how to set up a `CodeExecutorAgent` agent that uses the
:py:class:`~autogen_ext.code_executors.docker.DockerCommandLineCodeExecutor`
to execute code snippets in a Docker container. The `work_dir` parameter indicates where all executed files are first saved locally before being executed in the Docker container.