Nous ResearchHermes Agent
Deploy Now

Code Execution — Run Code Safely Inside Hermes

Key Points

  • Sandboxed Python execution
  • Safe by default — no filesystem access unless allowed
  • Install packages on the fly
  • Return charts, tables, and files
  • Persistent session state
  • Timeout protection

How It Works

  1. 1Ask Hermes to run code or analyze data
  2. 2Code executes in isolated sandbox
  3. 3Results returned as text, images, or files
  4. 4Session state persists across messages

Real-World Use Cases

Live Data Analysis

Upload a CSV or point Hermes at a database. It writes Python to clean, transform, and analyze the data in the sandbox, returning tables, statistics, and charts as actual output — not pseudocode you have to run yourself.

On-the-Fly Scripting

Need a one-off data transformation, file rename batch, or API test? Hermes writes the script and runs it immediately. If it fails, it reads the error, fixes the code, and retries — debugging in real time.

Reproducible Notebooks

Session state persists across messages — define a function in one message, call it in the next. Hermes maintains a live Python interpreter session, enabling iterative notebook-style workflows in plain chat.

Package Installation and Experimentation

Install any PyPI package on the fly during a session. Try out a new library, test an API client, or prototype with a framework — the sandbox handles dependency management without touching your system environment.

Under the Hood

The code execution sandbox is an isolated Python environment with configurable resource limits: execution timeout, memory cap, CPU time, and filesystem access controls. By default, the sandbox has no access to the host filesystem or network — it's fully air-gapped for safety. You can selectively enable filesystem access to specific directories or network access to specific endpoints when your use case requires it.

Session state persistence is implemented via a long-running Python interpreter process attached to the Hermes session. Variables, imported modules, and defined functions survive across messages in the same session, enabling genuine iterative development. The state is cleared when the session ends or when you explicitly request a reset. Charts and binary outputs (images, files) are base64-encoded and delivered inline in the response or as file attachments depending on the platform.

Code execution integrates with the Hermes tool ecosystem: the agent can read files into the sandbox, write sandbox outputs back to the filesystem, pass results to other tools (e.g., send a generated chart to Telegram, or store analysis results in memory), and spawn subagents to run parallel code execution workloads. The Programmatic Tool Calling feature allows collapsing multi-step code + tool pipelines into single inference calls, dramatically reducing latency for compute-intensive analytical workflows.

Related Features