Skip to content

Retry transient connection drops when opening a remote inference session#470

Open
vertix wants to merge 1 commit into
Positronic-Robotics:mainfrom
vertix:retry-inference-connect-resets
Open

Retry transient connection drops when opening a remote inference session#470
vertix wants to merge 1 commit into
Positronic-Robotics:mainfrom
vertix:retry-inference-connect-resets

Conversation

@vertix

@vertix vertix commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

InferenceClient.new_session retried only TimeoutError on connect, but a cold backend (e.g. a Modal container that scaled down between rollouts) can reset TLS or close the WebSocket handshake instead of timing out — surfacing as ssl.SSLError / websockets.ConnectionClosed. Those slipped past the retry loop and propagated up through the harness, killing an otherwise-healthy multi-rollout run on the first cold reconnect.

This widens the retried set to those two transient failure modes, so they back off and retry within the existing connect_deadline (like a cold-start timeout) instead of crashing the run. Genuine connection failures (other OSErrors) still surface immediately as before.

Test plan

  • Observed live: two remote-eval rollouts succeeded, the third new_session hit a cold Modal backend and died with ssl.SSLError: [SSL] internal errorConnectionClosedError; starting over reconnected fine, confirming the server was healthy and only cold.
  • ruff check / ruff format --check clean; module compiles.
  • Not yet re-run end-to-end against a cold backend on hardware.

A cold backend can reset TLS or close the handshake instead of timing out, surfacing as
`ssl.SSLError`/`ConnectionClosed`. The reconnect loop caught only `TimeoutError`, so a
mid-session cold start crashed the whole run. Retry these within the existing deadline.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f554269936

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# A cold backend fails before a session exists in any of three ways: the connect times out, the edge
# resets TLS (``SSLError``), or it closes the handshake (``ConnectionClosed``). All three mean "not
# ready yet", so retry them within the deadline instead of letting one kill the run.
except (TimeoutError, ssl.SSLError, ConnectionClosed) as e:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid retrying certificate verification failures

In secure deployments, ssl.SSLCertVerificationError is a subclass of ssl.SSLError, so an expired/invalid certificate, wrong TLS endpoint, or similar permanent TLS misconfiguration now gets treated as a cold-start transient and the caller sleeps/retries until the 900s default connect_deadline before receiving a misleading TimeoutError. These should still fail immediately (or be filtered out of the retried SSL errors) so bad TLS configuration is surfaced promptly.

Useful? React with 👍 / 👎.

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.

1 participant