Repository navigation
feat: add max_retries to the messages handler factories - #214
Conversation
3072cbf to
4bed864
Compare
4bed864 to
2c6228b
Compare
jeffdupont
left a comment
There was a problem hiding this comment.
This matches ai-sdks-monorepo#88 on every §1.1a rule. Keyword-only max_retries=None is validated at construction (bool refused), passed only when set, refused with llm or a model factory in LangChain, and forwarded by every wrapper, and model.parameters can't set it. The LiteLLM route rule is exactly what A.23 asks for: max_retries on openai/azure, num_retries elsewhere, an unresolvable model falling back to num_retries, plus the real-acompletion test that counts N + 1 requests on a non-OpenAI route.
Two small things:
- validate_max_retries should stay internal, since only handler packages call it. The suggestions below take it out of
__all__and the public-surface test. After applying them, runmake api-reportand commit the result: it removes thevalidate_max_retriesline frompackages/client/api-report/launchdarkly_ai_server.txt. The spec list should mark it "- # internal" too (asked on #88). - Three places cite "TESTING.md A.22" (litellm handler.py:141, test_utils.py:441, litellm test_handler.py:750). #88 has to be renumbered again because main now has A.22 and A.23, so please update them to whatever number it lands on. There are no suggestions for these because the number isn't settled yet.
Approve once those are in. Not a 1.0 blocker: it's additive, so it can ship in 1.1.
2c6228b to
a3f1d04
Compare
a3f1d04 to
500addb
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 500addb. Configure here.
500addb to
7040d29
Compare
jeffdupont
left a comment
There was a problem hiding this comment.
Thanks, this is ready.
validate_max_retriesis out of__all__but still importable from the package root for the handler packages, and the API report and public-surface test match.- Raising the handler packages' floor to
launchdarkly-ai-server>=1.1.0fixes the import Bugbot flagged: without it, upgrading only a handler package could pair it with a 1.0.0 server that has novalidate_max_retries.
I applied the PR to its base and ran the client and messages handler tests (2614 passed), the API report check and uv lock --check. All pass.
One small, non-blocking change, and it replaces my earlier ask to update the section numbers: three comments cite sections of a doc that isn't in this repo, so readers here can't follow them. The suggestions below drop the references and keep the rule in plain words. Fine to apply now or in a follow-up.

Add in a max retries passthrough argument to let handler factories natively retry.
Note
Overview
Adds an optional
max_retrieshandler factory argument across Claude, OpenAI, LangChain, and LiteLLM messages packages so callers can raise provider-level retry behavior (especially under shared rate limits) without putting retries in AI configmodel.parameters.launchdarkly-ai-servernow exposes sharedvalidate_max_retries(non-negative int orNone; rejects bools). Message packages bump their dependency tolaunchdarkly-ai-server>=1.1.0. Convenience wrappers popmax_retriesfrom kwargs so it does not reachconfig().Claude / OpenAI: when set, the value is passed into
AsyncAnthropic/AsyncOpenAIat client construction; omitted leaves the SDK default.model.parameters.max_retriesis not forwarded on individual API calls.LangChain: applies only when the handler builds the default chat model; **
max_retrieswith a customllmor factory raisesValueError.LiteLLM: per model route, sends
max_retriesfor OpenAI/Azure client routes andnum_retrieselsewhere (never both); unresolvable models usenum_retries.Public API reports and broad tests cover validation, defaults, invoke/stream/tool loops, and wrapper forwarding.
Reviewed by Cursor Bugbot for commit b1a73f3. Bugbot is set up for automated code reviews on this repo. Configure here.