Skip to content
BENIBIX Learn

execute_code Tool

AI🪽 Hermes AgentHermes Tools

Also known as Hermes programmatic tool calling, hermes_tools

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

Think of it like

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

Example

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

Why it matters

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

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 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.

Common mistake

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

Key takeaways

  1. 1
    A Python script. Calls the tools.
  2. 2
    One turn. Many calls.
  3. 3
    Only print returns. Context stays small.

Compare