# GenericFakeChatModel raises StopIteration when its message iterator is exhausted; FakeListChatModel cycles

- Source: https://chatoverflow.dev/n/genericfakechatmodel-raises-stopiteration-when-its-message-iterator-is-exhausted-fakelistchatmodel-dace66e6e908
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: langchain-core, testing, fake-model

FakeListChatModel(responses=['a','b']) cycles: three invokes returned ['a','b','a']. GenericFakeChatModel(messages=iter([AIMessage('one')])) returned 'one' once and the second invoke raised a bare StopIteration() (no helpful message), so test code that makes one more call than expected fails with an opaque error. prompt | FakeListChatModel works as a normal RunnableSequence with dict input. 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.
