Skip to content

Surface socket bind errors; handle old-generation Gemini UA merge order - #512

Open
zhulinchng wants to merge 1 commit into
databricks:mainfrom
zhulinchng:fix/socket-bind-error-and-gemini-ua
Open

Surface socket bind errors; handle old-generation Gemini UA merge order#512
zhulinchng wants to merge 1 commit into
databricks:mainfrom
zhulinchng:fix/socket-bind-error-and-gemini-ua

Conversation

@zhulinchng

Copy link
Copy Markdown

Fixes #511.

What changed

  • smart_routing/claude_pty.py: new _FirstPromptSocketThread carries an AF_UNIX bind failure outward as bind_error; run_claude_pty includes the socket path and reason in its RuntimeError (keeps the Claude was not launched suffix). A long $HOME no longer fails silently.
  • agents/gemini.py: corrected the render_env_overlay comment — a custom User-Agent in GEMINI_CLI_CUSTOM_HEADERS only wins on harness builds with the fixed merge order; older builds send their default GeminiCLI/... UA. Header itself still sent (forward-compatible; provider routing header unaffected).
  • Tests: first-prompt sockets bind in a short mkdtemp dir mirroring production (_short_socket_dir); Gemini wire-UA assertion stays strict on fixed generations and skips with reason on old ones; new test_bind_failure_names_the_reason and test_carries_custom_headers_override.
flowchart TD
    A[serve_first_prompt_socket] --> B{bind AF_UNIX path}
    B -->|ok| C[serve hook protocol]
    B -->|OSError| D[record thread.bind_error, exit]
    D --> E[launch error: path + reason + '; Claude was not launched']
    F[tests bind in short dir] --> C
Loading

Verification

  • Reproduced all 3 failures on clean main (see macOS: first-prompt socket fails silently on long paths; Gemini UA override dropped by old harness generations #511); new regression test proven fail-before via git stash (AttributeError: 'Thread' object has no attribute 'bind_error' pre-fix).
  • pytest --ignore=tests/test_e2e.py --ignore=tests/test_e2e_tracing.py: 2266 passed, 8 skipped (was 2262 passed, 7 skipped, 3 failed). Includes ruff check, ruff format --check, ty check via test_lint.py, plus live Gemini-wire and live PTY/socket harness tests.
  • test_e2e*.py not run — no UCODE_TEST_WORKSPACE bearer here.

- claude_pty: carry AF_UNIX bind failures out on the server thread so the
  launch error names the path and reason instead of a bare missing socket.
- gemini: correct the UA-override comment for old merge-order builds.
- tests: bind first-prompt sockets in short dirs (macOS tmp_path exceeds
  the AF_UNIX limit); skip Gemini wire-UA assertion with reason where the
  installed harness overwrites it; add bind-failure + runtime-env tests.
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.

macOS: first-prompt socket fails silently on long paths; Gemini UA override dropped by old harness generations

1 participant