Skip to content

fix: use short tmux sockets for overlong paths - #6038

Merged
jpshackelford merged 1 commit into
mainfrom
fix-tmux-socket-path-macos
Oct 17, 2026
Merged

jpshackelford merged 1 commit into
mainfrom
fix-tmux-socket-path-macos

Conversation

@jpshackelford

@jpshackelford jpshackelford commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

Test fixes for execution of suite on MacOS.


AGENT:

Why

Direct TmuxTerminal and TmuxPanePool sessions could fail on macOS with File name too long when TMUX_TMPDIR resolved into a deep temporary directory. Agent Server already measures tmux socket paths and falls back to /tmp, but direct terminal sessions did not.

Summary

  • Use the Agent Server's canonical-byte-length approach to select an explicit short /tmp tmux socket path when the original would exceed the platform's Unix-socket limit, without modifying the process-wide TMUX_TMPDIR.
  • Keep socket creation locking alongside the selected socket path.
  • Exercise real standalone and pooled terminal sessions under an overlong directory; give shared-socket Agent Server tests short temporary namespaces so they continue covering locking and cleanup.

Issue Number

Related to #5558, which documents deep TMUX_TMPDIR failures.

How to Test

On macOS, run pytest -q tests/tools/terminal/test_tmux_pane_pool.py tests/tools/terminal/test_tmux_log_redaction.py tests/agent_server/test_api.py (84 passed). Ruff, pycodestyle, and pyright checks on changed files also passed. An attempt to run all 412 tests under tests/tools/terminal was interrupted after 314 passed with no failures at about six minutes; the entire directory has not been verified.

Type

  • Bug fix

Notes

The HUMAN: note above is intentionally untouched; the author must provide their own note before the description validator can pass.

This PR was created by an AI agent (OpenHands) on behalf of the user.


🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)

• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python-slim amd64, arm64 python-node-runtime Link
python-minimal amd64, arm64 python-node-runtime Link
python amd64, arm64 python-node-runtime Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:0870a75-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-0870a75-python \
  ghcr.io/openhands/agent-server:0870a75-python

All tags pushed for this build

ghcr.io/openhands/agent-server:0870a75-golang-amd64
ghcr.io/openhands/agent-server:0870a753d7d7b71cd4fdccf0660d3466c3e46b8c-golang-amd64
ghcr.io/openhands/agent-server:fix-tmux-socket-path-macos-golang-amd64
ghcr.io/openhands/agent-server:0870a75-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:0870a75-golang-arm64
ghcr.io/openhands/agent-server:0870a753d7d7b71cd4fdccf0660d3466c3e46b8c-golang-arm64
ghcr.io/openhands/agent-server:fix-tmux-socket-path-macos-golang-arm64
ghcr.io/openhands/agent-server:0870a75-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:0870a75-java-amd64
ghcr.io/openhands/agent-server:0870a753d7d7b71cd4fdccf0660d3466c3e46b8c-java-amd64
ghcr.io/openhands/agent-server:fix-tmux-socket-path-macos-java-amd64
ghcr.io/openhands/agent-server:0870a75-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:0870a75-java-arm64
ghcr.io/openhands/agent-server:0870a753d7d7b71cd4fdccf0660d3466c3e46b8c-java-arm64
ghcr.io/openhands/agent-server:fix-tmux-socket-path-macos-java-arm64
ghcr.io/openhands/agent-server:0870a75-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:0870a75-python-amd64
ghcr.io/openhands/agent-server:0870a753d7d7b71cd4fdccf0660d3466c3e46b8c-python-amd64
ghcr.io/openhands/agent-server:fix-tmux-socket-path-macos-python-amd64
ghcr.io/openhands/agent-server:0870a75-python-node-runtime-amd64
ghcr.io/openhands/agent-server:0870a75-python-arm64
ghcr.io/openhands/agent-server:0870a753d7d7b71cd4fdccf0660d3466c3e46b8c-python-arm64
ghcr.io/openhands/agent-server:fix-tmux-socket-path-macos-python-arm64
ghcr.io/openhands/agent-server:0870a75-python-node-runtime-arm64
ghcr.io/openhands/agent-server:0870a75-python-minimal-amd64
ghcr.io/openhands/agent-server:0870a753d7d7b71cd4fdccf0660d3466c3e46b8c-python-minimal-amd64
ghcr.io/openhands/agent-server:fix-tmux-socket-path-macos-python-minimal-amd64
ghcr.io/openhands/agent-server:0870a75-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:0870a75-python-minimal-arm64
ghcr.io/openhands/agent-server:0870a753d7d7b71cd4fdccf0660d3466c3e46b8c-python-minimal-arm64
ghcr.io/openhands/agent-server:fix-tmux-socket-path-macos-python-minimal-arm64
ghcr.io/openhands/agent-server:0870a75-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:0870a75-python-slim-amd64
ghcr.io/openhands/agent-server:0870a753d7d7b71cd4fdccf0660d3466c3e46b8c-python-slim-amd64
ghcr.io/openhands/agent-server:fix-tmux-socket-path-macos-python-slim-amd64
ghcr.io/openhands/agent-server:0870a75-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:0870a75-python-slim-arm64
ghcr.io/openhands/agent-server:0870a753d7d7b71cd4fdccf0660d3466c3e46b8c-python-slim-arm64
ghcr.io/openhands/agent-server:fix-tmux-socket-path-macos-python-slim-arm64
ghcr.io/openhands/agent-server:0870a75-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:0870a75-golang
ghcr.io/openhands/agent-server:0870a753d7d7b71cd4fdccf0660d3466c3e46b8c-golang
ghcr.io/openhands/agent-server:fix-tmux-socket-path-macos-golang
ghcr.io/openhands/agent-server:0870a75-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:0870a75-java
ghcr.io/openhands/agent-server:0870a753d7d7b71cd4fdccf0660d3466c3e46b8c-java
ghcr.io/openhands/agent-server:fix-tmux-socket-path-macos-java
ghcr.io/openhands/agent-server:0870a75-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:0870a75-python-minimal
ghcr.io/openhands/agent-server:0870a753d7d7b71cd4fdccf0660d3466c3e46b8c-python-minimal
ghcr.io/openhands/agent-server:fix-tmux-socket-path-macos-python-minimal
ghcr.io/openhands/agent-server:0870a75-python-node-runtime-minimal
ghcr.io/openhands/agent-server:0870a75-python-slim
ghcr.io/openhands/agent-server:0870a753d7d7b71cd4fdccf0660d3466c3e46b8c-python-slim
ghcr.io/openhands/agent-server:fix-tmux-socket-path-macos-python-slim
ghcr.io/openhands/agent-server:0870a75-python-node-runtime-slim
ghcr.io/openhands/agent-server:0870a75-python
ghcr.io/openhands/agent-server:0870a753d7d7b71cd4fdccf0660d3466c3e46b8c-python
ghcr.io/openhands/agent-server:fix-tmux-socket-path-macos-python
ghcr.io/openhands/agent-server:0870a75-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., 0870a75-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., 0870a75-python-amd64) are also available if needed

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@jpshackelford
jpshackelford marked this pull request as ready for review October 16, 2026 21:14
@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-tools/openhands/tools/terminal/terminal
   tmux_terminal.py1567254%41–45, 49–50, 54–57, 139, 142, 207–208, 210, 213–216, 218, 220, 222, 224–225, 232–233, 237–238, 241–242, 247–251, 255, 258, 260–262, 266–271, 275–276, 293, 300–301, 306–307, 322, 344, 356–363, 371–372, 374–375, 377, 379–381
TOTAL509622058160% 

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was posted by an AI agent (OpenHands).

Scope. This belongs in this repository. It changes tmux socket-path selection in openhands-tools (the terminal tool this repo owns) and is the direct-terminal counterpart to the Agent Server logic already on main (_ensure_server_tmux_tmpdir in openhands-agent-server/openhands/agent_server/api.py). No cross-repository or product decision is involved.

Verification on head 0870a753 (Linux, tmux 3.5a, real tmux, no mocks).

  • Before/after on the real entry point: with TMUX_TMPDIR set to a 100-byte directory, origin/main raises libtmux.exc.LibTmuxException: ['error connecting to .../openhands-<32 hex> (File name too long)'] for both TmuxTerminal.initialize() and TmuxPanePool.initialize(). On this head the same script succeeds: both terminals create a real session, run a command, and read its output, with server.socket_path = /tmp/tmux-999/openhands-<32 hex>. This reproduces the #5558 symptom exactly, including when the deep directory does not yet exist.
  • The limit math matches the Agent Server: the same 42-byte openhands-<32 hex> name and the same 107 (Linux) / 103 (macOS, BSD) sun_path bound, measured from os.fsencode(os.path.realpath(...)), so the canonical macOS /tmp to /private/tmp expansion is accounted for on both sides.
  • Isolation and locking are preserved in the fallback path: each socket keeps its unique per-pool/per-terminal name, mark_socket_owner() is still recorded while holding the creation lock, and _socket_creation_lock(socket_dir) now locks the directory actually in use. The process-wide TMUX_TMPDIR is left unchanged, which the new test asserts and which keeps sibling sessions unaffected.
  • Tests: tests/tools/terminal plus tests/agent_server/test_api.py give 449 passed, 15 skipped on this head. The new test_overlong_tmux_tmpdir_uses_short_socket_path fails against the base module and passes on the head, so it is a real regression test. pre-commit run --files on the three changed files passes (ruff, ruff-format, pycodestyle, pyright, import rules, tool registration).
  • Current-head CI: every one of the 54 check runs on 0870a753 is success or skipped, with none failing. Linked issue #5558 is closed/completed, and its acceptance criteria are satisfied by this head together with the Agent Server logic already on main.

No material correctness, security, or compatibility findings.

✅ APPROVED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants