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

# 代码执行工具

> 了解如何使用 Agno 以及 Anthropic 的代码执行工具。

通过 Anthropic 的 [代码执行工具](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/code-execution-tool)，您的模型可以在安全、沙盒化的环境中执行 Python 代码。
这对于模型执行诸如分析数据、创建可视化或执行复杂计算等任务非常有用。

## 工作示例

```python theme={null}
from agno.agent import Agent
from agno.models.anthropic import Claude

agent = Agent(
    model=Claude(
        id="claude-sonnet-4-20250514",
        default_headers={
            "anthropic-beta": "code-execution-2025-05-22"
        }
    ),
    tools=[
        {
            "type": "code_execution_20250522",
            "name": "code_execution",
        }
    ],
    markdown=True,
)

agent.print_response("Calculate the mean and standard deviation of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]", stream=True)
```
