Skip to content

CodeExecutor

autogen.coding.CodeExecutor #

Bases: Protocol

(Experimental) A code executor class that executes code blocks and returns the result.

code_extractor property #

code_extractor

(Experimental) The code extractor used by this code executor.

execute_code_blocks #

execute_code_blocks(code_blocks)

(Experimental) Execute code blocks and return the result.

This method should be implemented by the code executor.

PARAMETER DESCRIPTION
code_blocks

The code blocks to execute.

TYPE: List[CodeBlock]

RETURNS DESCRIPTION
CodeResult

The result of the code execution.

TYPE: CodeResult

Source code in autogen/coding/base.py
def execute_code_blocks(self, code_blocks: list[CodeBlock]) -> CodeResult:
    """(Experimental) Execute code blocks and return the result.

    This method should be implemented by the code executor.

    Args:
        code_blocks (List[CodeBlock]): The code blocks to execute.

    Returns:
        CodeResult: The result of the code execution.
    """
    ...  # pragma: no cover

restart #

restart()

(Experimental) Restart the code executor.

This method should be implemented by the code executor.

This method is called when the agent is reset.

Source code in autogen/coding/base.py
def restart(self) -> None:
    """(Experimental) Restart the code executor.

    This method should be implemented by the code executor.

    This method is called when the agent is reset.
    """
    ...  # pragma: no cover