Repository navigation
feat: add max_retries to the messages handler factories - #214
aknight-ld wants to merge 1 commit into
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

Add in a max retries passthrough argument to let handler factories natively retry.
Note
Overview
Adds an optional
max_retriesargument on the Claude, OpenAI, LangChain, and LiteLLM messages handler factories and convenience wrappers, so callers can raise provider-level retry counts (for example under shared rate limits during batched evals) without touchingmodel.parameters.Shared validation lives in
validate_max_retriesinlaunchdarkly-ai-server(exported in 1.1.0): non-negativeintorNone; invalid types fail at handler construction. Omitted values are not passed through, preserving each vendor’s default (including 0 when explicitly set).model.parameterscannot override handler-level retries.Wiring differs by integration: Claude/OpenAI set
max_retriesonAsyncAnthropic/AsyncOpenAI; LangChain applies it only when the handler builds the default chat model (ValueErrorifllmis supplied); LiteLLM picksmax_retriesvsnum_retriesper model route (OpenAI/Azure vs everything else). Provider packages now requirelaunchdarkly-ai-server>=1.1.0.Tests cover forwarding, defaults, validation, and (for LiteLLM) end-to-end retry behavior on a failing route.
Reviewed by Cursor Bugbot for commit 7040d29. Bugbot is set up for automated code reviews on this repo. Configure here.