useStream.submit ignoring metadata on thread creation #298

Closed
opened 2026-02-15 18:15:37 -05:00 by yindo · 2 comments
Owner

Originally created by @SeveHo on GitHub (Jul 9, 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

When submitting to a stream, the new thread that gets created ignores config such as the metadata. This has severe downstream effects since applications might rely on metadata for things like access control. It seems like the line in the SDK is completely missing looking at the code.

Here is how I am submitting a new message for a new thread:

stream.submit(
  { messages: [...toolMessages, newMessage] },
  {
    metadata: {
      organization_id: orgId,
    },
    config: {
      configurable: {
        ...
      },
    },
    streamMode: ["values"],
    optimisticValues: (prev) => ({
      ...prev,
      messages: [...(prev.messages ?? []), ...toolMessages, newMessage],
    }),
  }
);

This is the code snippet of useStream.submit in the SDK (link):

let usableThreadId = threadId;
if (!usableThreadId) {
  const thread = await client.threads.create({
    threadId: submitOptions?.threadId,
  });
  onThreadId(thread.thread_id);
  usableThreadId = thread.thread_id;
}

Here is the resulting curl:

curl '<REDACTED>/threads' \
  <REDACTED> \
  --data-raw '{"metadata":{}}'

As far as I understand, this line should look more like this:

let usableThreadId = threadId;
if (!usableThreadId) {
  const thread = await client.threads.create({
    threadId: submitOptions?.threadId,
    metadata: submitOptions?.metadata,
    graphId: submitOptions?.graphId
  });
  onThreadId(thread.thread_id);
  usableThreadId = thread.thread_id;
}

Happy to open a PR but just want to confirm that I'm not missing anything.

Error Message and Stack Trace (if applicable)

No response

Description

See above

System Info

Node: v22.8.0
@langchain/langgraph-sdk: "^0.0.90",

Originally created by @SeveHo on GitHub (Jul 9, 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 When submitting to a stream, the new thread that gets created ignores config such as the metadata. This has severe downstream effects since applications might rely on metadata for things like access control. It seems like the line in the SDK is completely missing looking at the code. Here is how I am submitting a new message for a new thread: ```js stream.submit( { messages: [...toolMessages, newMessage] }, { metadata: { organization_id: orgId, }, config: { configurable: { ... }, }, streamMode: ["values"], optimisticValues: (prev) => ({ ...prev, messages: [...(prev.messages ?? []), ...toolMessages, newMessage], }), } ); ``` This is the code snippet of `useStream.submit` in the SDK ([link]( https://github.com/langchain-ai/langgraphjs/blob/ec61207573c8413a20fa11d5b74c78423f79e9b5/libs/sdk/src/react/stream.tsx#L1120)): ```ts let usableThreadId = threadId; if (!usableThreadId) { const thread = await client.threads.create({ threadId: submitOptions?.threadId, }); onThreadId(thread.thread_id); usableThreadId = thread.thread_id; } ``` Here is the resulting curl: ``` curl '<REDACTED>/threads' \ <REDACTED> \ --data-raw '{"metadata":{}}' ``` As far as I understand, this line should look more like this: ```ts let usableThreadId = threadId; if (!usableThreadId) { const thread = await client.threads.create({ threadId: submitOptions?.threadId, metadata: submitOptions?.metadata, graphId: submitOptions?.graphId }); onThreadId(thread.thread_id); usableThreadId = thread.thread_id; } ``` Happy to open a PR but just want to confirm that I'm not missing anything. ### Error Message and Stack Trace (if applicable) _No response_ ### Description See above ### System Info Node: v22.8.0 @langchain/langgraph-sdk: "^0.0.90",
yindo added the bug label 2026-02-15 18:15:37 -05:00
yindo closed this issue 2026-02-15 18:15:37 -05:00
Author
Owner

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

Will be fixed with next SDK version!

@dqbd commented on GitHub (Jul 9, 2025): Will be fixed with next SDK version!
Author
Owner

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

Fixed in 0.0.91!

@dqbd commented on GitHub (Jul 9, 2025): Fixed in `0.0.91`!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#298