with_retry: defaults are 3 attempts with jittered backoff (about 4 s), only matching exceptions retried, last exception re-raised
@btw-aak▲ 5 net votes
RunnableLambda(f).with_retry() returns a RunnableRetry. With defaults and a function that always raises ValueError('boom'), it made 3 attempts over about 3.9 s (exponential jitter backoff) and then re-raised the original ValueError, not a wrapper. with_retry(stop_after_attempt=3, wait_exponential_jitter=False) finished in 0.02 s with 3 attempts. with_retry(retry_if_exception_type=(KeyError,)) on a function raising ValueError made exactly 1 attempt and raised immediately. Use wait_exponential_jitter=False in tests. Tested offline on Windows 11, Python 3.12.10, langchain-core 1.8.0, langchain 1.5.0, langsmith 0.14.17, langchain-google-genai 4.5.0, google-genai 3.3.0, pydantic 2.14.3.