LangSmith studio context not properly passed to LangGraph #377

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

Originally created by @axelwijnants-ixor on GitHub (Nov 10, 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

import { createAgent, createMiddleware, SystemMessage } from 'langchain';
import { z } from 'zod';

const contextSchema = z.object({
  systemPromptRef: z.string(),
});

const agent = createAgent({
  name: 'testAgent',
  model: model,
  middleware: [dynamicPromptMiddleware],
  contextSchema: contextSchema,
});

const dynamicPromptMiddleware = createMiddleware({
  name: 'DynamicPrompt',
  beforeAgent: async (state, runtime) => {
    const systemMsg = runtime.context.systemPrompt ?? 'default test';

    return {
      messages: [new SystemMessage(systemMsg), ...state.messages],
    };
  },
  contextSchema: contextSchema,
});

export const testAgent = agent.graph;

Error Message and Stack Trace (if applicable)

No response

Description

The context passed through the LangSmith UI is not properly passed to the context object.

The parameter shows up in the LangSmith UI when I try to create a new assistant, but is not available on the context object when entering my custom middleware (the context object is empty).

I saw a related issue logged for LangchainJS: https://github.com/langchain-ai/langchainjs/issues/9222

The fix proposed here seems to solve my issue.

System Info

Node version: v22.16.0
Operating system: darwin arm64
Package manager: npm
Package manager version: 11.2.1

@langchain/core -> @1.0.3, , @"1.0.3", @"^1.0.1", @"^0.3.59, @"^1.0.0", @"^1.0.3"
langsmith -> @0.3.79, , @"^0.3.79", @"^0.3.64", @"^0.3.33", @"~0.3.74"
zod -> @3.25.76, , @"3.25.76"
@langchain/langgraph-cli -> @1.0.3, , @"1.0.3"
@langchain/langgraph-api -> @1.0.3, , @"1.0.3"
@langchain/langgraph-checkpoint -> @1.0.0, , @"^1.0.0", @"~0.0.16
@langchain/langgraph-sdk -> @1.0.0, , @"^1.0.0", @"~1.0.0", @"~0.0.16
@langchain/langgraph-ui -> @1.0.3, , @"1.0.3"
@langchain/langgraph -> @1.0.1, , @"1.0.1", @"^0.2.57, @"^0.2.72, @"^1.0.0"
@langchain/langgraph-supervisor -> @1.0.0, , @"1.0.0"
@langchain/mcp-adapters -> @1.0.0, , @"^1.0.0"
@langchain/openai -> @1.0.0, , @"1.0.0"
langchain -> @1.0.3, , @"^1.0.3"

Originally created by @axelwijnants-ixor on GitHub (Nov 10, 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 ```typescript import { createAgent, createMiddleware, SystemMessage } from 'langchain'; import { z } from 'zod'; const contextSchema = z.object({ systemPromptRef: z.string(), }); const agent = createAgent({ name: 'testAgent', model: model, middleware: [dynamicPromptMiddleware], contextSchema: contextSchema, }); const dynamicPromptMiddleware = createMiddleware({ name: 'DynamicPrompt', beforeAgent: async (state, runtime) => { const systemMsg = runtime.context.systemPrompt ?? 'default test'; return { messages: [new SystemMessage(systemMsg), ...state.messages], }; }, contextSchema: contextSchema, }); export const testAgent = agent.graph; ``` ### Error Message and Stack Trace (if applicable) _No response_ ### Description The context passed through the LangSmith UI is not properly passed to the context object. The parameter shows up in the LangSmith UI when I try to create a new assistant, but is not available on the context object when entering my custom middleware (the context object is empty). I saw a related issue logged for LangchainJS: https://github.com/langchain-ai/langchainjs/issues/9222 The fix proposed [here](https://github.com/langchain-ai/langchainjs/issues/9222#issuecomment-3417836619) seems to solve my issue. ### System Info Node version: v22.16.0 Operating system: darwin arm64 Package manager: npm Package manager version: 11.2.1 -------------------- @langchain/core -> @1.0.3, , @"1.0.3", @"^1.0.1", @"^0.3.59, @"^1.0.0", @"^1.0.3" langsmith -> @0.3.79, , @"^0.3.79", @"^0.3.64", @"^0.3.33", @"~0.3.74" zod -> @3.25.76, , @"3.25.76" @langchain/langgraph-cli -> @1.0.3, , @"1.0.3" @langchain/langgraph-api -> @1.0.3, , @"1.0.3" @langchain/langgraph-checkpoint -> @1.0.0, , @"^1.0.0", @"~0.0.16 @langchain/langgraph-sdk -> @1.0.0, , @"^1.0.0", @"~1.0.0", @"~0.0.16 @langchain/langgraph-ui -> @1.0.3, , @"1.0.3" @langchain/langgraph -> @1.0.1, , @"1.0.1", @"^0.2.57, @"^0.2.72, @"^1.0.0" @langchain/langgraph-supervisor -> @1.0.0, , @"1.0.0" @langchain/mcp-adapters -> @1.0.0, , @"^1.0.0" @langchain/openai -> @1.0.0, , @"1.0.0" langchain -> @1.0.3, , @"^1.0.3"
Author
Owner

@MartijnLeplae commented on GitHub (Nov 10, 2025):

@dqbd do you have time to look at this?

The issue seems to affect this part of the pregel code: https://github.com/langchain-ai/langgraphjs/blame/18abe1e813e1631a03bad39e20e64099d18d48d7/libs/langgraph-core/src/pregel/index.ts#L2013-L2018 which is part of this PR: https://github.com/langchain-ai/langgraphjs/pull/1451

config.context is {} and is not undefined while context.configurable contains the actual config/context

@MartijnLeplae commented on GitHub (Nov 10, 2025): @dqbd do you have time to look at this? The issue seems to affect this part of the pregel code: https://github.com/langchain-ai/langgraphjs/blame/18abe1e813e1631a03bad39e20e64099d18d48d7/libs/langgraph-core/src/pregel/index.ts#L2013-L2018 which is part of this PR: https://github.com/langchain-ai/langgraphjs/pull/1451 `config.context` is `{}` and is not `undefined` while `context.configurable` contains the actual config/context
Author
Owner

@ddewaele commented on GitHub (Nov 25, 2025):

Any updates on this ? Or should this be moved to the langchainjs repo ?

Is there an easy way to track all of these v1 issues because we've found that there are numerous "basic" functionalities that appear to be broken in v1 + lots of snippets on docs.langchain.com that simply don't work.

Some can be patched, others can be worked around, but it makes the adoption to v1 very painful.

@ddewaele commented on GitHub (Nov 25, 2025): Any updates on this ? Or should this be moved to the langchainjs repo ? Is there an easy way to track all of these v1 issues because we've found that there are numerous "basic" functionalities that appear to be broken in v1 + lots of snippets on [docs.langchain.com](https://docs.langchain.com/oss/javascript/langchain/overview) that simply don't work. Some can be patched, others can be worked around, but it makes the adoption to v1 very painful.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#377