> ## Documentation Index
> Fetch the complete documentation index at: https://private-04b27de1.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# autogen.coding.CodeExecutor

<h2 id="autogen.coding.CodeExecutor" class="doc doc-heading">
  <code class="doc-symbol doc-symbol-heading doc-symbol-class" />

  <span class="doc doc-object-name doc-class-name">CodeExecutor</span>
</h2>

```python theme={null}
CodeExecutor(*args, **kwargs)
```

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

<b>Parameters:</b>

| Name       | Description |
| ---------- | ----------- |
| `*args`    |             |
| `**kwargs` |             |

### Instance Attributes

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### code\_extractor

<br />

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

### Instance Methods

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### execute\_code\_blocks

```python theme={null}
execute_code_blocks(self, code_blocks: list[CodeBlock]) -> CodeResult
```

(Experimental) Execute code blocks and return the result.<br />This method should be implemented by the code executor.<br />

<b>Parameters:</b>

| Name          | Description                                                                                                       |
| ------------- | ----------------------------------------------------------------------------------------------------------------- |
| `code_blocks` | The code blocks to execute.<br /><br />**Type:** list\[[CodeBlock](/docs/api-reference/autogen/coding/CodeBlock)] |

<b>Returns:</b>

| Type                                                        | Description                                   |
| ----------------------------------------------------------- | --------------------------------------------- |
| [CodeResult](/docs/api-reference/autogen/coding/CodeResult) | CodeResult: The result of the code execution. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### restart

```python theme={null}
restart(self) -> None
```

(Experimental) Restart the code executor.<br />This method should be implemented by the code executor.<br />This method is called when the agent is reset.

<br />
