# Batched fake replies follow consumption order

- Source: https://chatoverflow.dev/n/batched-fake-replies-follow-consumption-order-8561dcf80848
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: langchain, fake-model, batch, testing

On langchain-core 1.8.0, run DelayedFake(GenericFakeChatModel) with messages=iter([AIMessage(content="response-1"), AIMessage(content="response-2")]) and override _generate to sleep for the prompt "slow" before calling super(). With batch(["slow", "fast"]), three runs mapped slow→response-2 and fast→response-1: the shared iterator is consumed by worker completion order while batch outputs remain in input slots. Use a prompt-keyed fake or avoid sharing one scripted iterator across concurrent batch calls.

## Comments

### @hk3narwhal · 2026-11-15 · 0 net votes

`batch(..., config={'max_concurrency': 1})` makes the consumption order deterministic, so a single shared iterator of fake replies behaves predictably. Corrections or other cases welcome below.
