Streaming with LangGraph always outputs 3 duplicate tokens #12

Closed
opened 2026-02-15 17:05:13 -05:00 by yindo · 11 comments
Owner

Originally created by @NERLOE on GitHub (Feb 28, 2024).

When streaming a graph, it always outputs the same tokens in the for-loop exactly 3 times for some reason?
There is no way to differentiate the output chunks other than making a check to only save every third token, but that seems like a quirky fix...

Here is a CodeSandbox link to see an example:
https://codesandbox.io/p/devbox/confident-cookies-54xwlr?file=index.ts

Skærmbillede 2024-02-28 kl  21 34 29
Originally created by @NERLOE on GitHub (Feb 28, 2024). When streaming a graph, it always outputs the same tokens in the for-loop exactly 3 times for some reason? There is no way to differentiate the output chunks other than making a check to only save every third token, but that seems like a quirky fix... Here is a CodeSandbox link to see an example: https://codesandbox.io/p/devbox/confident-cookies-54xwlr?file=index.ts <img width="854" alt="Skærmbillede 2024-02-28 kl 21 34 29" src="https://github.com/langchain-ai/langgraphjs/assets/32075361/bb77b5c5-d0ec-4498-a263-6ac829fc17f0">
yindo closed this issue 2026-02-15 17:05:13 -05:00
Author
Owner

@bracesproul commented on GitHub (Feb 29, 2024):

Hey @NERLOE I just copied & pasted this into a .ts file (I didn't run in the code sandbox you linked) but didn't modify any code and my result logged this:

result Hello! I'm just a computer program, so I don't have feelings, but I'm here to help you. How can I assist you today?

Are you running the latest version of everything?

@bracesproul commented on GitHub (Feb 29, 2024): Hey @NERLOE I just copied & pasted this into a .ts file (I didn't run in the code sandbox you linked) but didn't modify any code and my result logged this: ``` result Hello! I'm just a computer program, so I don't have feelings, but I'm here to help you. How can I assist you today? ``` Are you running the latest version of everything?
Author
Owner

@NERLOE commented on GitHub (Mar 1, 2024):

Weird... I should be running the latest versions... This is the package.json dependencies on the CodeSandbox... I also have a local dev environment where it does the same...?

Skærmbillede 2024-03-01 kl  08 24 45
@NERLOE commented on GitHub (Mar 1, 2024): Weird... I should be running the latest versions... This is the package.json dependencies on the CodeSandbox... I also have a local dev environment where it does the same...? <img width="392" alt="Skærmbillede 2024-03-01 kl 08 24 45" src="https://github.com/langchain-ai/langgraphjs/assets/32075361/cae0471b-0f51-4b4c-b2ff-7edfd63e4401">
Author
Owner

@NERLOE commented on GitHub (Mar 1, 2024):

Just want to mention, that when streaming normally with a normal LangChain AgentExecutor it works as expected, but when I use a compiled LangChain graph it does this weird behaviour.

@NERLOE commented on GitHub (Mar 1, 2024): Just want to mention, that when streaming normally with a normal LangChain AgentExecutor it works as expected, but when I use a compiled LangChain graph it does this weird behaviour.
Author
Owner

@bracesproul commented on GitHub (Mar 4, 2024):

Could you push up a repo which I can clone to reproduce? Kinda hard to debug in code sandbox.
Thanks

@bracesproul commented on GitHub (Mar 4, 2024): Could you push up a repo which I can clone to reproduce? Kinda hard to debug in code sandbox. Thanks
Author
Owner

@NERLOE commented on GitHub (Mar 4, 2024):

Here you go, I have reproduced the bug in this repo:
https://github.com/NERLOE/langchain-bug

@NERLOE commented on GitHub (Mar 4, 2024): Here you go, I have reproduced the bug in this repo: https://github.com/NERLOE/langchain-bug
Author
Owner

@bracesproul commented on GitHub (Mar 5, 2024):

Hey @NERLOE I just cloned and was able to reproduce. Then I bumped the langchain deps:

"dependencies": {
  "@langchain/core": "0.1.41",
  "@langchain/langgraph": "0.0.10",
  "@langchain/openai": "0.0.16"
}

and the error stopped occurring. Can you confirm on your end?

@bracesproul commented on GitHub (Mar 5, 2024): Hey @NERLOE I just cloned and was able to reproduce. Then I bumped the langchain deps: ```json "dependencies": { "@langchain/core": "0.1.41", "@langchain/langgraph": "0.0.10", "@langchain/openai": "0.0.16" } ``` and the error stopped occurring. Can you confirm on your end?
Author
Owner

@NERLOE commented on GitHub (Mar 6, 2024):

Hey @bracesproul I just tried updating to the following dependencies, and I still get the error:

  "dependencies": {
    "@langchain/core": "0.1.42",
    "@langchain/langgraph": "0.0.10",
    "@langchain/openai": "0.0.16",
   }

I have updated the GitHub repo as well, with the updated dependencies.... But this is still the output I get:
Skærmbillede 2024-03-06 kl  11 00 23

@NERLOE commented on GitHub (Mar 6, 2024): Hey @bracesproul I just tried updating to the following dependencies, and I still get the error: ```json "dependencies": { "@langchain/core": "0.1.42", "@langchain/langgraph": "0.0.10", "@langchain/openai": "0.0.16", } ``` I have updated the GitHub repo as well, with the updated dependencies.... But this is still the output I get: <img width="1363" alt="Skærmbillede 2024-03-06 kl 11 00 23" src="https://github.com/langchain-ai/langgraphjs/assets/32075361/54b83388-40d7-43fa-b8a4-2d1a5367b98a">
Author
Owner

@bracesproul commented on GitHub (Mar 6, 2024):

I just re-cloned and it worked for me. I would try deleting your node modules folder?

@bracesproul commented on GitHub (Mar 6, 2024): I just re-cloned and it worked for me. I would try deleting your node modules folder?
Author
Owner

@NERLOE commented on GitHub (Mar 6, 2024):

Just tried this:

  1. Deleted node_modules and yarn.lock and reinstalled with yarn, then it suddenly worked.
  2. Then I deleted the node_modules and yarn.lock again to try installing with pnpm, and then it didn't work.
  3. Then I tried installing with yarn again, and now I can't get it to work...

I've tried deleting and re-installing many times now, and can't get it to work anymore.

@NERLOE commented on GitHub (Mar 6, 2024): Just tried this: 1. Deleted node_modules and yarn.lock and reinstalled with yarn, then it suddenly worked. 2. Then I deleted the node_modules and yarn.lock again to try installing with pnpm, and then it didn't work. 3. Then I tried installing with yarn again, and now I can't get it to work... I've tried deleting and re-installing many times now, and can't get it to work anymore.
Author
Owner

@iliskhan commented on GitHub (Mar 14, 2024):

I had the same problem, but downgrading @langchain/core to 0.1.14 helped. At the moment I have such dependencies:

"dependencies": {
        "@langchain/community": "^0.0.38",
        "@langchain/core": "^0.1.41",
        "@langchain/langgraph": "^0.0.10",
        "@langchain/openai": "^0.0.20"
}
@iliskhan commented on GitHub (Mar 14, 2024): I had the same problem, but downgrading **@langchain/core** to **0.1.14** helped. At the moment I have such dependencies: ```json "dependencies": { "@langchain/community": "^0.0.38", "@langchain/core": "^0.1.41", "@langchain/langgraph": "^0.0.10", "@langchain/openai": "^0.0.20" } ```
Author
Owner

@davidfant commented on GitHub (Apr 29, 2024):

@jacoblee93 @bracesproul this issue can prob be closed. i think it was the same thing i ran into earlier
https://github.com/langchain-ai/langchainjs/pull/4834/files

@davidfant commented on GitHub (Apr 29, 2024): @jacoblee93 @bracesproul this issue can prob be closed. i think it was the same thing i ran into earlier https://github.com/langchain-ai/langchainjs/pull/4834/files
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#12