useStream config not working with langgraph 0.6.0 new Context API #317

Closed
opened 2026-02-15 18:15:51 -05:00 by yindo · 1 comment
Owner

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

Server:

class ContextSchema(BaseModel):
    model_provider: Literal["anthropic", "openai", "google_genai", "groq"] = Field(
        default="google_genai",
    )
    model_name: Literal[
        "gpt-4o",
        "o3",
        "gpt-4.1",
        "claude-opus-4-0",
        "claude-sonnet-4-0",
        "gemini-2.5-flash",
        "gemini-2.5-pro",
        "moonshotai/kimi-k2-instruct",
    ] = Field(
        default="gemini-2.5-flash",
    )

def call_model(state: State, runtime: Runtime[ContextSchema]) -> State:

    # initialize the actual model call
    model_kwargs = {
        "model": runtime.context.model_name + ":" + runtime.context.model_provider,
        "temperature": runtime.context.temperature,
    }

    model = init_chat_model(**model_kwargs)

    model_with_tools = model.bind_tools(tools)
    response = model_with_tools.invoke(state["messages"])

    return {"messages": [response]}


tool_node = ToolNode(tools=tools)

# Define the graph
graph = (
    StateGraph(state_schema=State, context_schema=ContextSchema)
    .add_node("model", call_model)
    .add_node("tools", tool_node)
    .add_edge(START, "model")
    .add_edge("tools", "model")
    .add_conditional_edges("model", tools_condition)
    .compile(name="Graph")
)

Client

...
    stream.submit(
      { messages: [...toolMessages, newMessage] },
      {
        metadata: {
          organization_id: orgId,
          user_id: userId,
        },
        config: {
          configurable: {
            model_provider,
            model_name,
          },
        },
        streamMode: ["messages"],
      }
    );

Error Message and Stack Trace (if applicable)

On the server this throws the message:

AttributeError: 'NoneType' object has no attribute 'model_name'

And on the client there seems to be no way to pass the new context as typescript complains right away.

Description

@langchain/langgraph-sdk useStream is not allowing me to pass context according to the new Context API. The config values get ignored and the server throws an error not even picking the default value. See code and error above.

System Info

Server:

langgraph==0.6.0

Client:

"@langchain/core": "^0.3.66",
"@langchain/langgraph": "^0.3.11",
"@langchain/langgraph-sdk": "^0.0.103",
Originally created by @SeveHo on GitHub (Jul 29, 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 **Server:** ```py class ContextSchema(BaseModel): model_provider: Literal["anthropic", "openai", "google_genai", "groq"] = Field( default="google_genai", ) model_name: Literal[ "gpt-4o", "o3", "gpt-4.1", "claude-opus-4-0", "claude-sonnet-4-0", "gemini-2.5-flash", "gemini-2.5-pro", "moonshotai/kimi-k2-instruct", ] = Field( default="gemini-2.5-flash", ) def call_model(state: State, runtime: Runtime[ContextSchema]) -> State: # initialize the actual model call model_kwargs = { "model": runtime.context.model_name + ":" + runtime.context.model_provider, "temperature": runtime.context.temperature, } model = init_chat_model(**model_kwargs) model_with_tools = model.bind_tools(tools) response = model_with_tools.invoke(state["messages"]) return {"messages": [response]} tool_node = ToolNode(tools=tools) # Define the graph graph = ( StateGraph(state_schema=State, context_schema=ContextSchema) .add_node("model", call_model) .add_node("tools", tool_node) .add_edge(START, "model") .add_edge("tools", "model") .add_conditional_edges("model", tools_condition) .compile(name="Graph") ) ``` **Client** ```js ... stream.submit( { messages: [...toolMessages, newMessage] }, { metadata: { organization_id: orgId, user_id: userId, }, config: { configurable: { model_provider, model_name, }, }, streamMode: ["messages"], } ); ``` ### Error Message and Stack Trace (if applicable) On the server this throws the message: ``` AttributeError: 'NoneType' object has no attribute 'model_name' ``` And on the client there seems to be no way to pass the new context as typescript complains right away. ### Description @langchain/langgraph-sdk useStream is not allowing me to pass context according to the new Context API. The config values get ignored and the server throws an error not even picking the default value. See code and error above. ### System Info Server: ``` langgraph==0.6.0 ``` Client: ``` "@langchain/core": "^0.3.66", "@langchain/langgraph": "^0.3.11", "@langchain/langgraph-sdk": "^0.0.103", ```
yindo closed this issue 2026-02-15 18:15:51 -05:00
Author
Owner

@sydney-runkle commented on GitHub (Jul 29, 2025):

@dqbd, could you please take a look?

@sydney-runkle commented on GitHub (Jul 29, 2025): @dqbd, could you please take a look?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#317