Skip to content

Conversation

@niilooy
Copy link
Contributor

@niilooy niilooy commented Oct 28, 2025

Overview

Expanded docs for accessing and handling the recursion counter in LangGraph graphs, enabling developers to implement proactive recursion management before hitting limits.

Type of change

Type: Update existing documentation

Checklist

  • I have read the contributing guidelines
  • I have tested my changes locally using docs dev
  • All code examples have been tested and work correctly
  • I have used root relative paths for internal links
  • [n/a] I have updated navigation in src/docs.json if needed
  • I have gotten approval from the relevant reviewers

Additional notes

This PR extends the existing "Recursion limit" section in the Graph API documentation with detailed guidance on accessing config.metadata.langgraph_step and implementing proactive recursion handling.

What's Added

1. How it works - Explains where the step counter is stored and how the recursion limit check logic works in both Python (config["metadata"]["langgraph_step"]) and TypeScript (config.metadata.langgraph_step).

2. Accessing the current step counter - Simple code examples showing how to read the step counter within node functions.

3. Proactive recursion handling - Complete working examples demonstrating:

  • Checking if approaching the limit (e.g., 80% threshold)
  • Routing to fallback nodes before hitting the limit
  • Full graph setup with conditional edges for graceful degradation

4. Proactive vs reactive approaches - Side-by-side comparison including:

  • Code examples of both proactive monitoring and reactive error catching
  • Comparison table highlighting detection timing, handling location, and control flow differences
  • Lists of advantages for each approach with recommendation for proactive handling

5. Other available metadata - Documents additional metadata fields available in config (node, triggers, path, checkpoint namespace).

Motivation

Currently, the documentation explains the recursion limit configuration but doesn't cover how developers can access the current step counter or implement proactive handling strategies. This leads developers to only discover reactive error handling (catching GraphRecursionError) rather than implementing graceful degradation patterns within their graphs. This addition enables better user experiences by allowing graphs to complete normally with partial results rather than throwing exceptions.

…ling in graph-api

This commit includes:

- Explanation of config.metadata.langgraph_step access in nodes
- Code examples for checking step counter
- Proactive recursion handling patterns for graceful degradation
- Comparison of proactive vs reactive approaches with advantages
- Documentation of other available metadata fields

The proactive approach allows developers to route to fallback nodes
before hitting recursion limits, enabling better user experience with
partial results instead of exceptions.
@niilooy niilooy requested a review from lnhsingh as a code owner October 28, 2025 18:51
@github-actions github-actions bot added langgraph For docs changes to LangGraph oss labels Oct 28, 2025
@niilooy niilooy requested a review from l2and October 28, 2025 18:51
@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-docsla-1761677510-d3f3233

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

langgraph For docs changes to LangGraph oss

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants