🐛 Bug Report: recursionLimit varying during graph execution #368

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

Originally created by @luizzappa on GitHub (Oct 18, 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

Reproduction: https://stackblitz.com/~/github.com/luizzappa/langgraphjs-starter-template

Error Message and Stack Trace (if applicable)

No response

Description

The recursionLimit value is inconsistent across nodes during a single graph execution. It changes from 24 to 25 between different nodes, when it should remain constant at the value passed during invocation (25). The bug appears to be with the conditional edge.

Reproduction

https://stackblitz.com/~/github.com/luizzappa/langgraphjs-starter-template

my-app/graph.ts

const preStart = async (_: StateT, config?: RunnableConfig) => {
  console.debug(`config node: preStart, recursion Limit:' ${config?.recursionLimit}, ${config?.metadata?.langgraph_node}, Step: ${config?.metadata?.langgraph_step}`);
  return { stringList: [] };
}

const callModel = async (state: StateT, config?: RunnableConfig) => {
  console.debug(`config node: callModel, recursion Limit:' ${config?.recursionLimit}, ${config?.metadata?.langgraph_node}, Step: ${config?.metadata?.langgraph_step}`);
  return { stringList: [state.input, "b", "c"] };
};

export const _route = (state: StateT, config?: RunnableConfig): "__end__" | "callModel" => {
  console.debug(`config node: _route, recursion Limit:' ${config?.recursionLimit}, ${config?.metadata?.langgraph_node}, Step: ${config?.metadata?.langgraph_step}`);
  if (state.stringList.length > 0) {
    return "__end__";
  }
  return "callModel";
};

const workflow = new StateGraph(State)
  .addNode("callModel", callModel)
  .addNode("preStart", preStart)
  .addEdge("__start__", "preStart")
  .addEdge("preStart", "callModel")
  .addConditionalEdges("callModel", _route);

Then just run npm run test -- graph.init.test.ts

Look at the console.debug:

Image

Expected Behavior

When invoking a graph with recursionLimit: 25, all nodes should receive config.recursionLimit === 25 throughout the entire execution.

Actual Behavior

The recursionLimit varies between 24 and 25 during execution:

  • Step 1 (preStart node): recursionLimit = 25
  • Step 2 (callModel node): recursionLimit = 25
  • Step 2 (_route function): recursionLimit = 24

System Info

"@langchain/langgraph": "^0.3.6"

Originally created by @luizzappa on GitHub (Oct 18, 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 Reproduction: https://stackblitz.com/~/github.com/luizzappa/langgraphjs-starter-template ### Error Message and Stack Trace (if applicable) _No response_ ### Description The `recursionLimit` value is inconsistent across nodes during a single graph execution. It changes from 24 to 25 between different nodes, when it should remain constant at the value passed during invocation (25). **The bug appears to be with the conditional edge.** ### Reproduction https://stackblitz.com/~/github.com/luizzappa/langgraphjs-starter-template `my-app/graph.ts` ```ts const preStart = async (_: StateT, config?: RunnableConfig) => { console.debug(`config node: preStart, recursion Limit:' ${config?.recursionLimit}, ${config?.metadata?.langgraph_node}, Step: ${config?.metadata?.langgraph_step}`); return { stringList: [] }; } const callModel = async (state: StateT, config?: RunnableConfig) => { console.debug(`config node: callModel, recursion Limit:' ${config?.recursionLimit}, ${config?.metadata?.langgraph_node}, Step: ${config?.metadata?.langgraph_step}`); return { stringList: [state.input, "b", "c"] }; }; export const _route = (state: StateT, config?: RunnableConfig): "__end__" | "callModel" => { console.debug(`config node: _route, recursion Limit:' ${config?.recursionLimit}, ${config?.metadata?.langgraph_node}, Step: ${config?.metadata?.langgraph_step}`); if (state.stringList.length > 0) { return "__end__"; } return "callModel"; }; const workflow = new StateGraph(State) .addNode("callModel", callModel) .addNode("preStart", preStart) .addEdge("__start__", "preStart") .addEdge("preStart", "callModel") .addConditionalEdges("callModel", _route); ``` Then just run `npm run test -- graph.init.test.ts` Look at the `console.debug`: <img width="286" height="192" alt="Image" src="https://github.com/user-attachments/assets/96b2921f-cd2c-44ed-9fb3-e0df34110b98" /> ### Expected Behavior When invoking a graph with `recursionLimit`: 25, all nodes should receive `config.recursionLimit` === 25 throughout the entire execution. ### Actual Behavior The `recursionLimit` varies between 24 and 25 during execution: - Step 1 (preStart node): recursionLimit = 25 - Step 2 (callModel node): recursionLimit = 25 - Step 2 (_route function): recursionLimit = 24 ### System Info "@langchain/langgraph": "^0.3.6"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#368