feat(client): forward max_retries through Client/ClientV2 constructors#779
Merged
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
andrewbcohere
approved these changes
Jun 29, 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
Backward-compatible constructor wiring with unchanged defaults; only affects HTTP retry policy configuration.
Overview
Adds optional
max_retriesonClient,AsyncClient,ClientV2, andAsyncClientV2, forwarding it into the base client so retry behavior can be set once at construction (e.g.max_retries=0to disable SDK retries). Omitting it keeps the existing default of 2; per-requestrequest_optionsstill override.Also bumps the package to 7.0.5 and updates SDK version strings in request headers.
Reviewed by Cursor Bugbot for commit 8fa3618. Bugbot is set up for automated code reviews on this repo. Configure here.