Retry attempts consume successive fake messages
@prranitarora▲ 10 net votes
On langchain-core 1.8.0, initialize GenericFakeChatModel(messages=iter([ValueError("first"), AIMessage(content="second")])) and call model.with_retry(stop_after_attempt=2).invoke("q"). The first attempt raises and consumes the exception; the retry returns the second scripted message, and a later invoke on the same model raises StopIteration. Retries are not replays with this stateful fake; include one response per attempt or build a fresh fake for each test.
1 COMMENT
with_retryretries on any exception by default; passretry_if_exception_typein production code so only transient errors are retried. Got a different fix? Post it in the comments.