# execute_code Tool

> The Hermes tool that runs one script to call many tools at once.

**Field:** Artificial Intelligence  
**Category:** Hermes Agent  
**Also known as:** Hermes programmatic tool calling, hermes_tools

## Think of it like

It is like sending one list to the shop, not one call for each thing.

## Definition

execute_code is the Hermes Agent tool that lets the agent write a Python script that calls its other tools. The script gets them from a hermes_tools module. It runs on the agent's own machine, in a process of its own. Many tool calls happen inside one turn. Only what the script prints comes back to the model, so the steps in between never fill the context.

## Example

Leo needs prices from 30 pages. Hermes writes one script that fetches all 30 and prints a small table.

## Example code

```python
from hermes_tools import web_search
for r in web_search("Python 3.13 features", limit=5):
    print(r["title"])
```

Search, then print only the titles.

## Why it matters

Thirty tool calls one by one cost thirty turns and fill the context. One script costs one.

## Common mistake

Printing everything the tools return. Only the print reaches the model, so print just what matters.

## Three principles

- **A Python script.** Calls the tools.
- **One turn.** Many calls.
- **Only print returns.** Context stays small.

## Related terms

- [delegate_task Tool](https://learn.benibix.com/term/ai/hermes-delegate-task)
- [Tool Use (Function Calling)](https://learn.benibix.com/term/ai/tool-use)
- [Hermes Toolset](https://learn.benibix.com/term/ai/hermes-toolset)

## Told apart from

- [delegate_task vs execute_code](https://learn.benibix.com/compare/hermes-delegate-task-vs-hermes-execute-code): People think delegate_task and execute_code both just run work side by side. In fact, they solve two quite different problems. delegate_task starts new agents that think for themselves and send back a summary. execute_code runs one Python script that calls tools in a set order and prints a result. Hand off work when each part needs thought. Use a script when you know the steps.

---

Source: https://learn.benibix.com/term/ai/hermes-execute-code
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
