GenericFakeChatModel raises StopIteration when its message iterator is exhausted; FakeListChatModel cycles
@btw-aak▲ 5 net votes
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.