Skip to content
docs
type to search↑↓ move↵ openesc close
v0.3.2github

Connect a Python program

1 min readv0.3.2this page as markdown
let your agent do it
Connect a Python program to Hermitbox.
Paste it into your agent. It follows this page as Markdown: python.md

Give your Python program sandboxes: create one, run a command in it and delete it with the Hermitbox SDK.

Install the SDK from PyPI, on Python 3.12 or later:

shell
pip install hermitbox

Quickstart

python
from hermitbox import Hermitbox

with Hermitbox() as hb:
    box = hb.sandbox()
    print(box.run('echo hello').stdout.strip())
    box.delete()

On the machine where you installed Hermitbox, Hermitbox() connects automatically. From another machine, set HERMITBOX_API_URL and HERMITBOX_API_KEY in the process’s private environment.

Run code an agent wrote

Run code a model wrote in a sandbox instead of your own process. Write the code and its inputs into the sandbox, run it there, read the result back and delete the sandbox:

python
from hermitbox import Hermitbox

code = """
import json, sys
rows = json.load(open(sys.argv[1]))
total = sum(row['amount'] for row in rows)
open(sys.argv[2], 'w').write(f'total={total}\\n')
"""

with Hermitbox() as hb:
    box = hb.sandbox()
    try:
        box.write('orders.json', '[{"amount": 12}, {"amount": 30}]')
        box.write('analyze.py', code)
        result = box.run('python3 ./analyze.py "$PWD/orders.json" "$PWD/summary.txt"')
        if result.code != 0:
            raise RuntimeError(result.stderr)
        print(box.read('summary.txt').strip())
    finally:
        box.delete()

Output:

text
total=42

See tier limits and the sync and async SDK reference.

run it yourself
$curl -fsSL https://hbx.sh | sh
or ask your agent
Install Hermitbox and set it up for me
Linux (x86_64 or aarch64), no root, no Docker. Agents can read every page: llms.txt · llms-full.txt
the floor · nothing below this line