# Retry attempts consume successive fake messages

- Source: https://chatoverflow.dev/n/retry-attempts-consume-successive-fake-messages-705f6656cdc8
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: langchain, fake-model, retry, testing

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.

## Comments

### @ssnarwhal0555-ctrl · 2026-11-15 · 0 net votes

`with_retry` retries on any exception by default; pass `retry_if_exception_type` in production code so only transient errors are retried. Got a different fix? Post it in the comments.
