Skip to content

Detect dead model connections after a network drop - #1451

Draft
fazxes wants to merge 2 commits into
mainfrom
fazxes/detect-dead-model-connections
Draft

fazxes wants to merge 2 commits into
mainfrom
fazxes/detect-dead-model-connections

Conversation

@fazxes

@fazxes fazxes commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • After a network drop mid-answer, fx notices that the server no longer knows the connection within about 5 seconds of the network returning, and retries the request instead of waiting up to 10 minutes on a silent stream.
  • During a longer outage, fx reports the connection as lost 45 seconds after the last data arrived and keeps retrying until the network returns.
  • A model that thinks silently for minutes keeps its connection, because the server answers the keepalive probes.
  • The same detection covers the AI Gateway and the chat completions, OpenAI Codex, and xAI providers.
  • If the system refuses a keepalive option on a connection, the request continues as before and the debug trace records which option failed.
  • fx no longer closes a model connection when it detects that the Mac slept. Even a brief sleep used to cut a healthy answer and restart it. A connection that died while the Mac slept is now found by the keepalive probes after it wakes.

- After a network drop mid-answer, fx notices that the server no longer knows the connection within about 5 seconds of the network returning, and retries the request instead of waiting up to 10 minutes on a silent stream.
- During a longer outage, fx reports the connection as lost 45 seconds after the last data arrived and keeps retrying until the network returns.
- A model that thinks silently for minutes keeps its connection, because the server answers the keepalive probes.
- The same detection covers the AI Gateway and the chat completions, OpenAI Codex, and xAI providers.
- If the system refuses a keepalive option on a connection, the request continues as before and the debug trace records which option failed.
@fazxes fazxes added the type: bug Fixes incorrect behavior label Oct 24, 2026
During a model request, fx compared two clocks every 10 ms and closed
the connection when they drifted more than 100 ms apart, taking that as
a sign the Mac had slept. Even a brief sleep closed a healthy answer in
the middle and restarted it.

fx no longer watches for sleep. A connection that died while the Mac
slept is found by the dead-peer probes after it wakes and is resent like
any other dropped connection.

This branch has not been deployed

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

Labels

type: bug Fixes incorrect behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant