feat: add declarative reconnect flag with transport-factory auto-disable#720
Open
GregHolmes wants to merge 1 commit into
Open
feat: add declarative reconnect flag with transport-factory auto-disable#720GregHolmes wants to merge 1 commit into
GregHolmes wants to merge 1 commit into
Conversation
Add `reconnect: bool = True` to DeepgramClient and AsyncDeepgramClient. When a custom `transport_factory` is provided, `reconnect` is auto-set to `False` to signal that the custom transport owns its own retry/reconnect lifecycle. Stored on `self.reconnect` for inspection. The Python SDK has no wrapper reconnect layer today (the `websockets` library doesn't auto-reconnect; transports manage their own reconnects), so this flag is declarative only — it documents intent and is reserved for any future SDK-side reconnect logic. Custom transports such as SageMaker already own their retry lifecycle, so double-stacking SDK-side retries on top would cause storm-on-storm under burst load. Tests cover the default, explicit False, transport_factory auto-disable, and the explicit-True override that opts back in.
VWang1111
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
reconnect: bool = Truekwarg toDeepgramClientandAsyncDeepgramClient. When a customtransport_factoryis provided,reconnectis auto-set toFalseto signal that the custom transport owns its own retry/reconnect lifecycle.Why
Custom transports (e.g., the SageMaker transport in
deepgram-python-sdk-transport-sagemaker) implement their own retry and reconnect logic — full-jitter backoff, retry-budget windows, replay buffers, etc. Stacking SDK-level retries on top of that would cause storm-on-storm behavior under burst load, which is the failure mode that motivated this parity work across the SDKs.This adds an explicit, declarative way to express "the SDK is not responsible for reconnects." Today the Python SDK has no wrapper reconnect layer (the
websocketslibrary doesn't auto-reconnect; transports manage their own), so the flag is declarative only: it documents intent and reserves the slot for any future SDK-side reconnect logic.Parity with other SDKs
reconnectparity work indeepgram-java-sdkdeepgram-js-sdkin PR Python SDK examples websocket async_http bug #492 (gh/pluggable-transport-sagemaker)Behavior
Test plan
Covered in
tests/custom/test_transport.py:client.reconnect == Truereconnect=Falseis respectedtransport_factoryauto-disables →reconnect == Falsetransport_factory=..., reconnect=Trueis respectedRelease impact
feat:→ minor version bump per release-please conventionssrc/deepgram/client.py, already in.fernignore