prebuilt createReactAgent can not work with streamEvents #122

Closed
opened 2026-02-15 17:15:59 -05:00 by yindo · 5 comments
Owner

Originally created by @Wulino on GitHub (Oct 23, 2024).

Bug Report: Stream Events with ChatMessageChunk

Description

I am trying to implement a fully streaming call using this.agentExecutor.stream(xxx)(this is not fully streaming), and everything was working fine initially. However, after making the following changes:

this.agentExecutor = createReactAgent({
  llm: this.chatModel,
  tools,
  messageModifier: prompt,
});
this.agentExecutor.streamEvents(
  { messages },
  {
    version: 'v2',
  },
);

20241023144113

image

So, is there anyway to achieve Streaming LLM Tokens? I have been struggling with this issue for many days. ReactAgent without streaming is really terrible!!

Originally created by @Wulino on GitHub (Oct 23, 2024). # Bug Report: Stream Events with ChatMessageChunk ## Description I am trying to implement a fully streaming call using `this.agentExecutor.stream(xxx)`(this is not fully streaming), and everything was working fine initially. However, after making the following changes: ```ts this.agentExecutor = createReactAgent({ llm: this.chatModel, tools, messageModifier: prompt, }); this.agentExecutor.streamEvents( { messages }, { version: 'v2', }, ); ``` ![20241023144113](https://github.com/user-attachments/assets/e69bae99-a9aa-4371-8ede-0c115faac3c9) ![image](https://github.com/user-attachments/assets/4b9a046a-f74e-4bb3-bdf7-e27fce4a85a9) So, is there anyway to achieve Streaming LLM Tokens? I have been struggling with this issue for many days. ReactAgent without streaming is really terrible!!
yindo closed this issue 2026-02-15 17:15:59 -05:00
Author
Owner

@jacoblee93 commented on GitHub (Oct 23, 2024):

What model are you using?

@jacoblee93 commented on GitHub (Oct 23, 2024): What model are you using?
Author
Owner

@Wulino commented on GitHub (Oct 23, 2024):

What model are you using?

It's trained By my company, just like ChatGPT. The llm class is based on @langchain/openai/ChatOpenAi, and I have only modified the input and output parameters of the API. So I think it's same as ChatGPT.
I believe the model itself is not the issue; it seems more like there are problems with the entire workflow's support for streamEvents, right? cause both "invoke" and "stream" are working as expected.

By the way, since I don't have a ChatGPT API key, is there anyone who can help me try using ChatGPT or other models to see if there are any issues with createReactAgent and streamEvents? This way, I can figure out exactly where the problem lies.

@Wulino commented on GitHub (Oct 23, 2024): > What model are you using? It's trained By my company, just like ChatGPT. The llm class is based on @langchain/openai/ChatOpenAi, and I have only modified the input and output parameters of the API. So I think it's same as ChatGPT. I believe the model itself is not the issue; it seems more like there are problems with the entire workflow's support for streamEvents, right? cause both "invoke" and "stream" are working as expected. By the way, since I don't have a ChatGPT API key, is there anyone who can help me try using ChatGPT or other models to see if there are any issues with createReactAgent and streamEvents? This way, I can figure out exactly where the problem lies.
Author
Owner

@jacoblee93 commented on GitHub (Oct 25, 2024):

So I think it's same as ChatGPT. I believe the model itself is not the issue; it seems more like there are problems with the entire workflow's support for streamEvents, right? cause both "invoke" and "stream" are working as expected.

Can you double check this by calling model.streamEvents on your implementation? As far as I know this works for OpenAI

@jacoblee93 commented on GitHub (Oct 25, 2024): > So I think it's same as ChatGPT. I believe the model itself is not the issue; it seems more like there are problems with the entire workflow's support for streamEvents, right? cause both "invoke" and "stream" are working as expected. Can you double check this by calling `model.streamEvents` on your implementation? As far as I know this works for OpenAI
Author
Owner

@fiachra commented on GitHub (Nov 29, 2024):

@Wulino Hey just FYI, I hit this problem using LiteLLM but when I swapped to a direct Azure connection it went away. I was using the same model in both examples just LiteLLM is the proxy in the middle in the failed example. I don't know the difference yet but it does seem to be an interface issue.

@fiachra commented on GitHub (Nov 29, 2024): @Wulino Hey just FYI, I hit this problem using [LiteLLM](https://www.litellm.ai/) but when I swapped to a direct Azure connection it went away. I was using the same model in both examples just LiteLLM is the proxy in the middle in the failed example. I don't know the difference yet but it does seem to be an interface issue.
Author
Owner

@dqbd commented on GitHub (Jul 8, 2025):

Hello! I believe this to be an issue with the underlying LLM interface implementation not emitting AI Message chunks properly. If you're hitting this issue with an officially supported package, feel free to open a new issue.

@dqbd commented on GitHub (Jul 8, 2025): Hello! I believe this to be an issue with the underlying LLM interface implementation not emitting AI Message chunks properly. If you're hitting this issue with an officially supported package, feel free to open a new issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#122