feat(client): forward max_retries through Client/ClientV2 constructors#779
Open
fern-support wants to merge 1 commit into
Open
feat(client): forward max_retries through Client/ClientV2 constructors#779fern-support wants to merge 1 commit into
fern-support wants to merge 1 commit into
Conversation
The base BaseCohere/AsyncBaseCohere constructors accept `max_retries`, but the hand-maintained Client, AsyncClient, ClientV2 and AsyncClientV2 override constructors never exposed it, so it could not be set at the client level (only per-request via request_options). Thread `max_retries: Optional[int] = None` through all four override constructors, forwarding to the respective super().__init__. The None default preserves the existing behavior (base applies its default of 2).
andrewbcohere
approved these changes
Jun 26, 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
Makes
max_retriesconfigurable from the client constructors. Requested by Cohere (handle retries centrally outside the SDK; the default of 2 made that hard to enforce).The base
BaseCohere/AsyncBaseCohereconstructors already acceptmax_retries, but the hand-maintained override constructors inclient.py/client_v2.pynever forwarded it — somax_retriescould only be set per-request viarequest_options, not at the client level. (These files are.fernignore'd, sofern generatenever touches them; this had to be a manual edit.)Changes
Thread
max_retries: typing.Optional[int] = Nonethrough all four override constructors, forwarding to the respectivesuper().__init__:Client→BaseCohereAsyncClient→AsyncBaseCohereClientV2→ClientAsyncClientV2→AsyncClientThe
Nonedefault preserves existing behavior: the base client applies its own default of2. Per-requestmax_retriesinrequest_optionscontinues to take precedence.Usage
Verification
inspect.signature(...).parameterscontainsmax_retriesforClient,AsyncClient,ClientV2,AsyncClientV2.max_retries=0stores0on the client wrapper; instantiating without it stores the base default of2.timeoutis still forwarded for all four (regression guard).mypy src/cohere/client.py src/cohere/client_v2.py— clean.test_client_init,test_overrides,test_embed_utils,test_embed_streaming).Note
Low Risk
Constructor-only plumbing with
Nonepreserving prior defaults; no change to retry logic itself.Overview
Adds optional
max_retriestoClient,AsyncClient,ClientV2, andAsyncClientV2so callers can set SDK-level retry behavior at construction (e.g.max_retries=0to disable the default of 2).The hand-maintained overrides in
client.pyandclient_v2.pynow acceptmax_retries: typing.Optional[int] = Noneand pass it through toBaseCohere/AsyncBaseCohere(and V2 wrappers delegate viaClient/AsyncClient). Omitting the argument keeps the existing base default; per-requestrequest_optionsmax_retriesstill overrides the client default.Reviewed by Cursor Bugbot for commit df151d6. Bugbot is set up for automated code reviews on this repo. Configure here.