I want to use WebBrowser now. Could you please tell me how to pass the no-stream parameter into it? #363

Open
opened 2026-02-15 18:16:12 -05:00 by yindo · 3 comments
Owner

Originally created by @lzj960515 on GitHub (Sep 23, 2025).

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangGraph.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangGraph.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangGraph (or the specific integration package).

Example Code

new WebBrowser({         
  model: new ChatOpenAI({ temperature: 0 }),         
  embeddings: new OpenAIEmbeddings(), 
}),

Error Message and Stack Trace (if applicable)

Link: https://github.com/langchain-ai/langgraphjs/issues/1538

Description

This is clearly a bug, I don't know why this issue was closed. @dqbd

System Info

Latest

Originally created by @lzj960515 on GitHub (Sep 23, 2025). ### Checked other resources - [x] I added a very descriptive title to this issue. - [x] I searched the LangGraph.js documentation with the integrated search. - [x] I used the GitHub search to find a similar question and didn't find it. - [x] I am sure that this is a bug in LangGraph.js rather than my code. - [x] The bug is not resolved by updating to the latest stable version of LangGraph (or the specific integration package). ### Example Code ``` new WebBrowser({ model: new ChatOpenAI({ temperature: 0 }), embeddings: new OpenAIEmbeddings(), }), ``` ### Error Message and Stack Trace (if applicable) Link: https://github.com/langchain-ai/langgraphjs/issues/1538 ### Description This is clearly a bug, I don't know why this issue was closed. @dqbd ### System Info Latest
Author
Owner

@lzj960515 commented on GitHub (Sep 23, 2025):

And I think it is ridiculous to write "no stream" in invoke. Isn't invoke no-stream? Shouldn't the correct way to write it is to write the stream tag in invoke?

const processTool = tool(
  async ({ input }) => {
    console.log("🔧 TOOL: Starting non-streaming invoke() call...");

    // This should be completely non-streaming, no output should leak
    const chain = RunnableSequence.from([
      llm,
      new StringOutputParser(),
    ]).withConfig({ tags: ["nostream"] }); // it's should be tags: ["stream"]

    const result = await chain.invoke([
      { role: "user", content: `Convert to uppercase: ${input}` },
    ]);
    console.log("✅ TOOL: Non-streaming invoke() completed");
    return `Processed: ${result}`;
  },
  {
    name: "processTool",
    schema: z.object({ input: z.string() }),
  },
);
@lzj960515 commented on GitHub (Sep 23, 2025): And I think it is ridiculous to write "no stream" in invoke. Isn't invoke no-stream? Shouldn't the correct way to write it is to write the stream tag in invoke? ``` const processTool = tool( async ({ input }) => { console.log("🔧 TOOL: Starting non-streaming invoke() call..."); // This should be completely non-streaming, no output should leak const chain = RunnableSequence.from([ llm, new StringOutputParser(), ]).withConfig({ tags: ["nostream"] }); // it's should be tags: ["stream"] const result = await chain.invoke([ { role: "user", content: `Convert to uppercase: ${input}` }, ]); console.log("✅ TOOL: Non-streaming invoke() completed"); return `Processed: ${result}`; }, { name: "processTool", schema: z.object({ input: z.string() }), }, ); ```
Author
Owner

@lzj960515 commented on GitHub (Sep 23, 2025):

This is a complete example. I think it's important to let everyone know about this, rather than secretly closing the issue and covering it up.

/**
 * Bug Reproduction: Non-streaming tool invoke() calls leak streaming data
 * 
 * Root cause: initializeAsyncLocalStorageSingleton() in @langchain/langgraph/dist/index.js:4
 * Triggered by: import { getCurrentTaskInput } from '@langchain/langgraph'
 */

import { StringOutputParser } from 'npm:@langchain/core/output_parsers';
import { RunnableSequence } from 'npm:@langchain/core/runnables';
import { tool } from 'npm:@langchain/core/tools';
import { createReactAgent } from 'npm:@langchain/langgraph/prebuilt';
import { ChatOpenAI } from 'npm:@langchain/openai';
import 'npm:dotenv/config';
import z from 'npm:zod';

// This import triggers the bug by loading langgraph/index.js
import 'npm:@langchain/langgraph';

const llm = new ChatOpenAI({ model: 'gpt-4o-mini' });

const processTool = tool(
  async ({ input }) => {
    console.log("🔧 TOOL: Starting non-streaming invoke() call...");
    
    // This should be completely non-streaming, no output should leak
    const chain = RunnableSequence.from([llm, new StringOutputParser()]);
    const result = await chain.invoke([
      { role: 'user', content: `Convert to uppercase: ${input}` }
    ]);
    
    console.log("✅ TOOL: Non-streaming invoke() completed");
    return `Processed: ${result}`;
  },
  {
    name: 'processTool',
    schema: z.object({ input: z.string() }),
  },
);

const agent = createReactAgent({ llm, tools: [processTool] });

console.log("🚀 Streaming test - watch for data leakage during tool execution");
console.log("=" .repeat(70));

const stream = await agent.stream(
  { messages: 'Use the tool to process "test data"' },
  { streamMode: 'messages' }
);

let chunkNumber = 0;
for await (const [chunk] of stream) {
  if (!chunk.content) continue;
  
  chunkNumber++;
  const chunkType = Object.prototype.toString.call(chunk);
  const preview = chunk.content.substring(0, 50);
  
  console.log(`${chunkNumber.toString().padStart(2, '0')}. ${chunkType}: ${preview}${chunk.content.length > 50 ? '...' : ''}`);
}

console.log("=" .repeat(70));
console.log("🔍 ANALYSIS:");
console.log("- Look for AIMessageChunk entries between 'TOOL: Starting' and 'TOOL: completed'");
console.log("- Those chunks contain data from the internal invoke() call");
console.log("- This should NOT happen - invoke() is non-streaming");
console.log("- Root cause: AsyncLocalStorage initialization breaks stream isolation");
@lzj960515 commented on GitHub (Sep 23, 2025): This is a complete example. I think it's important to let everyone know about this, rather than secretly closing the issue and covering it up. ```typescript /** * Bug Reproduction: Non-streaming tool invoke() calls leak streaming data * * Root cause: initializeAsyncLocalStorageSingleton() in @langchain/langgraph/dist/index.js:4 * Triggered by: import { getCurrentTaskInput } from '@langchain/langgraph' */ import { StringOutputParser } from 'npm:@langchain/core/output_parsers'; import { RunnableSequence } from 'npm:@langchain/core/runnables'; import { tool } from 'npm:@langchain/core/tools'; import { createReactAgent } from 'npm:@langchain/langgraph/prebuilt'; import { ChatOpenAI } from 'npm:@langchain/openai'; import 'npm:dotenv/config'; import z from 'npm:zod'; // This import triggers the bug by loading langgraph/index.js import 'npm:@langchain/langgraph'; const llm = new ChatOpenAI({ model: 'gpt-4o-mini' }); const processTool = tool( async ({ input }) => { console.log("🔧 TOOL: Starting non-streaming invoke() call..."); // This should be completely non-streaming, no output should leak const chain = RunnableSequence.from([llm, new StringOutputParser()]); const result = await chain.invoke([ { role: 'user', content: `Convert to uppercase: ${input}` } ]); console.log("✅ TOOL: Non-streaming invoke() completed"); return `Processed: ${result}`; }, { name: 'processTool', schema: z.object({ input: z.string() }), }, ); const agent = createReactAgent({ llm, tools: [processTool] }); console.log("🚀 Streaming test - watch for data leakage during tool execution"); console.log("=" .repeat(70)); const stream = await agent.stream( { messages: 'Use the tool to process "test data"' }, { streamMode: 'messages' } ); let chunkNumber = 0; for await (const [chunk] of stream) { if (!chunk.content) continue; chunkNumber++; const chunkType = Object.prototype.toString.call(chunk); const preview = chunk.content.substring(0, 50); console.log(`${chunkNumber.toString().padStart(2, '0')}. ${chunkType}: ${preview}${chunk.content.length > 50 ? '...' : ''}`); } console.log("=" .repeat(70)); console.log("🔍 ANALYSIS:"); console.log("- Look for AIMessageChunk entries between 'TOOL: Starting' and 'TOOL: completed'"); console.log("- Those chunks contain data from the internal invoke() call"); console.log("- This should NOT happen - invoke() is non-streaming"); console.log("- Root cause: AsyncLocalStorage initialization breaks stream isolation"); ```
Author
Owner

@Diluka commented on GitHub (Sep 23, 2025):

This is a complete example. I think it's important to let everyone know about this, rather than secretly closing the issue and covering it up.

/**
 * Bug Reproduction: Non-streaming tool invoke() calls leak streaming data
 * 
 * Root cause: initializeAsyncLocalStorageSingleton() in @langchain/langgraph/dist/index.js:4
 * Triggered by: import { getCurrentTaskInput } from '@langchain/langgraph'
 */

import { StringOutputParser } from 'npm:@langchain/core/output_parsers';
import { RunnableSequence } from 'npm:@langchain/core/runnables';
import { tool } from 'npm:@langchain/core/tools';
import { createReactAgent } from 'npm:@langchain/langgraph/prebuilt';
import { ChatOpenAI } from 'npm:@langchain/openai';
import 'npm:dotenv/config';
import z from 'npm:zod';

// This import triggers the bug by loading langgraph/index.js
import 'npm:@langchain/langgraph';

const llm = new ChatOpenAI({ model: 'gpt-4o-mini' });

const processTool = tool(
  async ({ input }) => {
    console.log("🔧 TOOL: Starting non-streaming invoke() call...");
    
    // This should be completely non-streaming, no output should leak
    const chain = RunnableSequence.from([llm, new StringOutputParser()]);
    const result = await chain.invoke([
      { role: 'user', content: `Convert to uppercase: ${input}` }
    ]);
    
    console.log("✅ TOOL: Non-streaming invoke() completed");
    return `Processed: ${result}`;
  },
  {
    name: 'processTool',
    schema: z.object({ input: z.string() }),
  },
);

const agent = createReactAgent({ llm, tools: [processTool] });

console.log("🚀 Streaming test - watch for data leakage during tool execution");
console.log("=" .repeat(70));

const stream = await agent.stream(
  { messages: 'Use the tool to process "test data"' },
  { streamMode: 'messages' }
);

let chunkNumber = 0;
for await (const [chunk] of stream) {
  if (!chunk.content) continue;
  
  chunkNumber++;
  const chunkType = Object.prototype.toString.call(chunk);
  const preview = chunk.content.substring(0, 50);
  
  console.log(`${chunkNumber.toString().padStart(2, '0')}. ${chunkType}: ${preview}${chunk.content.length > 50 ? '...' : ''}`);
}

console.log("=" .repeat(70));
console.log("🔍 ANALYSIS:");
console.log("- Look for AIMessageChunk entries between 'TOOL: Starting' and 'TOOL: completed'");
console.log("- Those chunks contain data from the internal invoke() call");
console.log("- This should NOT happen - invoke() is non-streaming");
console.log("- Root cause: AsyncLocalStorage initialization breaks stream isolation");

I have tried this example, and even if I add nostream, it has no effect.

@Diluka commented on GitHub (Sep 23, 2025): > This is a complete example. I think it's important to let everyone know about this, rather than secretly closing the issue and covering it up. > > ```typescript > /** > * Bug Reproduction: Non-streaming tool invoke() calls leak streaming data > * > * Root cause: initializeAsyncLocalStorageSingleton() in @langchain/langgraph/dist/index.js:4 > * Triggered by: import { getCurrentTaskInput } from '@langchain/langgraph' > */ > > import { StringOutputParser } from 'npm:@langchain/core/output_parsers'; > import { RunnableSequence } from 'npm:@langchain/core/runnables'; > import { tool } from 'npm:@langchain/core/tools'; > import { createReactAgent } from 'npm:@langchain/langgraph/prebuilt'; > import { ChatOpenAI } from 'npm:@langchain/openai'; > import 'npm:dotenv/config'; > import z from 'npm:zod'; > > // This import triggers the bug by loading langgraph/index.js > import 'npm:@langchain/langgraph'; > > const llm = new ChatOpenAI({ model: 'gpt-4o-mini' }); > > const processTool = tool( > async ({ input }) => { > console.log("🔧 TOOL: Starting non-streaming invoke() call..."); > > // This should be completely non-streaming, no output should leak > const chain = RunnableSequence.from([llm, new StringOutputParser()]); > const result = await chain.invoke([ > { role: 'user', content: `Convert to uppercase: ${input}` } > ]); > > console.log("✅ TOOL: Non-streaming invoke() completed"); > return `Processed: ${result}`; > }, > { > name: 'processTool', > schema: z.object({ input: z.string() }), > }, > ); > > const agent = createReactAgent({ llm, tools: [processTool] }); > > console.log("🚀 Streaming test - watch for data leakage during tool execution"); > console.log("=" .repeat(70)); > > const stream = await agent.stream( > { messages: 'Use the tool to process "test data"' }, > { streamMode: 'messages' } > ); > > let chunkNumber = 0; > for await (const [chunk] of stream) { > if (!chunk.content) continue; > > chunkNumber++; > const chunkType = Object.prototype.toString.call(chunk); > const preview = chunk.content.substring(0, 50); > > console.log(`${chunkNumber.toString().padStart(2, '0')}. ${chunkType}: ${preview}${chunk.content.length > 50 ? '...' : ''}`); > } > > console.log("=" .repeat(70)); > console.log("🔍 ANALYSIS:"); > console.log("- Look for AIMessageChunk entries between 'TOOL: Starting' and 'TOOL: completed'"); > console.log("- Those chunks contain data from the internal invoke() call"); > console.log("- This should NOT happen - invoke() is non-streaming"); > console.log("- Root cause: AsyncLocalStorage initialization breaks stream isolation"); > ``` I have tried this example, and even if I add nostream, it has no effect.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#363