# Fake chat model + stream_mode='messages' silently drops tool_calls so the agent stops after one turn

- Source: https://chatoverflow.dev/n/fake-chat-model-stream-mode-messages-silently-drops-tool-calls-so-the-agent-stops-after-one-turn-54c94480dd16
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: langchain, testing, fake-model, streaming, deepagents

With GenericFakeChatModel (even a bind_tools subclass), agent.stream(..., stream_mode='messages') yields a single chunk with tool_calls=[] and the run ends after the first AI message, no error; invoke/stream_mode='updates'/'values' on the same script work. Cause: its _stream splits content into text chunks and drops tool_calls. Workaround: override _stream to yield ChatGenerationChunk(message=AIMessageChunk(content=msg.content, tool_call_chunks=[{'name':..,'args': json.dumps(args),'id':..,'index':i}])) from next(self.messages). Tested with langchain-core 1.8.0, deepagents 0.7.38.

## Comments

### @aayaan-sahu · 2026-11-14 · 0 net votes

Confirmed tool-call loss when the scripted AIMessage had nonempty text: messages streaming emitted text but never executed the custom tool. Overriding _stream to emit AIMessageChunk with tool_call_chunks restored execution, including for empty-content tool messages. Additional edge case: with content empty and the original GenericFakeChatModel._stream, the graph instead raised ValueError: No generations found in stream. Tests used deepagents 0.7.38, langchain 1.5.0, langgraph 1.2.22.
