Summary
On Linux, execute_code always fails with OSError: AF_UNIX path too long when the host process's TMPDIR is longer than roughly the length of /tmp (i.e. whenever TMPDIR isn't literally /tmp). Every call returns tool_calls_made: 0 — the sandbox never starts.
Root cause
tools/code_execution_tool.py (around line 1200–1263, v0.18.2) builds the sandbox RPC socket path as:
_sock_tmpdir = "/tmp" if sys.platform == "darwin" else tempfile.gettempdir()
...
sock_path = os.path.join(_sock_tmpdir, f"hermes_rpc_{uuid.uuid4().hex}.sock")
...
server_sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
server_sock.bind(sock_path) # line 1263 — raises here
The comment above this code says: "On Linux, tempfile.gettempdir() already returns /tmp" — but that's only true when TMPDIR/TMP/TEMP are unset. Any host that sets a longer TMPDIR (e.g. for per-task/per-workspace sandbox isolation) pushes tempfile.gettempdir() well past a short path, and the appended hermes_rpc_<32-hex-chars>.sock filename (~51 chars) then blows past Linux's sun_path limit (108 bytes, ~107 usable).
Concretely, with a 117-char TMPDIR the resulting socket path was 166 chars — bind() fails every time with OSError: AF_UNIX path too long.
The macOS branch already works around a version of this same problem (avoiding the long /var/folders/... TMPDIR), but the Linux branch assumes the default tempdir is always short, which isn't true once TMPDIR is overridden.
Suggested fix
Drop the darwin-only special case and always anchor the sandbox socket at a short, fixed directory (e.g. always use /tmp regardless of sys.platform, or fall back to /tmp whenever len(sock_path) > 100), instead of trusting tempfile.gettempdir() on Linux.
Environment
- hermes-agent 0.18.2
- Linux
- Triggered whenever the host process sets a
TMPDIR longer than a few chars before launching hermes (e.g. per-task temp dir isolation)
Impact
execute_code is completely non-functional under these conditions — every invocation fails immediately with 0 tool calls made.
Summary
On Linux,
execute_codealways fails withOSError: AF_UNIX path too longwhen the host process'sTMPDIRis longer than roughly the length of/tmp(i.e. wheneverTMPDIRisn't literally/tmp). Every call returnstool_calls_made: 0— the sandbox never starts.Root cause
tools/code_execution_tool.py(around line 1200–1263, v0.18.2) builds the sandbox RPC socket path as:The comment above this code says: "On Linux, tempfile.gettempdir() already returns /tmp" — but that's only true when
TMPDIR/TMP/TEMPare unset. Any host that sets a longerTMPDIR(e.g. for per-task/per-workspace sandbox isolation) pushestempfile.gettempdir()well past a short path, and the appendedhermes_rpc_<32-hex-chars>.sockfilename (~51 chars) then blows past Linux'ssun_pathlimit (108 bytes, ~107 usable).Concretely, with a 117-char
TMPDIRthe resulting socket path was 166 chars —bind()fails every time withOSError: AF_UNIX path too long.The macOS branch already works around a version of this same problem (avoiding the long
/var/folders/...TMPDIR), but the Linux branch assumes the default tempdir is always short, which isn't true onceTMPDIRis overridden.Suggested fix
Drop the
darwin-only special case and always anchor the sandbox socket at a short, fixed directory (e.g. always use/tmpregardless ofsys.platform, or fall back to/tmpwheneverlen(sock_path) > 100), instead of trustingtempfile.gettempdir()on Linux.Environment
TMPDIRlonger than a few chars before launching hermes (e.g. per-task temp dir isolation)Impact
execute_codeis completely non-functional under these conditions — every invocation fails immediately with 0 tool calls made.