[Question] Max Number of steps seems equal to 13-ish? #6

Closed
opened 2026-02-20 17:21:33 -05:00 by yindo · 2 comments
Owner

Originally created by @zhentao-xu on GitHub (Jan 15, 2024).

Hi, when I create a graph, compile it to chain, and invoke it, the chain just stop in the middle.

Here is a very simple example to reproduce this

import types
from typing import Optional

from langgraph.graph import Graph

from src.langgraph.agents.common import copy_func
from loguru import logger


def copy_func(f, new_name: str = None):
    return types.FunctionType(f.__code__,
                              f.__globals__,
                              new_name or f.__name__,
                              f.__defaults__,
                              f.__closure__)


def mk_noop_node(node_name: str, logger_msg: Optional[str] = None):
    def _noop(data):
        if logger_msg is not None:
            logger.info(logger_msg)
        return data

    _noop = copy_func(_noop, node_name)
    return _noop


graph = Graph()

# Create and add 100 noop nodes to the graph
for i in range(100):
    node_name = f"noop_node_{i}"
    logger_msg = f"Executing {node_name}"
    noop_node = mk_noop_node(node_name, logger_msg)
    graph.add_node(node_name, noop_node)

    # Link the nodes in sequence
    if i > 0:
        previous_node_name = f"noop_node_{i - 1}"
        graph.add_edge(previous_node_name, node_name)

# Set the entry point to the first node
graph.set_entry_point("noop_node_0")

# Optionally, if you want to mark an end to the graph
graph.set_finish_point(f"noop_node_{99}")

chain = graph.compile()

# Example of invoking the graph
initial_data = {"message": "Start of the graph"}
result = chain.invoke(initial_data)

Here is the result
image

Originally created by @zhentao-xu on GitHub (Jan 15, 2024). Hi, when I create a graph, compile it to chain, and invoke it, the chain just stop in the middle. Here is a very simple example to reproduce this ```python import types from typing import Optional from langgraph.graph import Graph from src.langgraph.agents.common import copy_func from loguru import logger def copy_func(f, new_name: str = None): return types.FunctionType(f.__code__, f.__globals__, new_name or f.__name__, f.__defaults__, f.__closure__) def mk_noop_node(node_name: str, logger_msg: Optional[str] = None): def _noop(data): if logger_msg is not None: logger.info(logger_msg) return data _noop = copy_func(_noop, node_name) return _noop graph = Graph() # Create and add 100 noop nodes to the graph for i in range(100): node_name = f"noop_node_{i}" logger_msg = f"Executing {node_name}" noop_node = mk_noop_node(node_name, logger_msg) graph.add_node(node_name, noop_node) # Link the nodes in sequence if i > 0: previous_node_name = f"noop_node_{i - 1}" graph.add_edge(previous_node_name, node_name) # Set the entry point to the first node graph.set_entry_point("noop_node_0") # Optionally, if you want to mark an end to the graph graph.set_finish_point(f"noop_node_{99}") chain = graph.compile() # Example of invoking the graph initial_data = {"message": "Start of the graph"} result = chain.invoke(initial_data) ``` Here is the result <img width="832" alt="image" src="https://github.com/langchain-ai/langgraph/assets/126112554/2925292a-1a47-413d-bf51-2dd711674065">
yindo closed this issue 2026-02-20 17:21:35 -05:00
Author
Owner

@zhentao-xu commented on GitHub (Jan 15, 2024):

aha, never mind, I found the reason is that there is "recursion_limit" key.

resolved with

chain = graph.compile().with_config({"recursion_limit": 100})

@zhentao-xu commented on GitHub (Jan 15, 2024): aha, never mind, I found the reason is that there is "recursion_limit" key. resolved with ```python chain = graph.compile().with_config({"recursion_limit": 100}) ```
Author
Owner

@nfcampos commented on GitHub (Jan 15, 2024):

Yes you can update recursion limit to something better for your use case

@nfcampos commented on GitHub (Jan 15, 2024): Yes you can update recursion limit to something better for your use case
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#6