[PR #1166] [MERGED] (docs): add examples on recursion counter access and proactive handling in graph-api #1354

Closed
opened 2026-02-17 17:22:12 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/docs/pull/1166
Author: @niilooy
Created: 10/28/2025
Status: Merged
Merged: 11/6/2025
Merged by: @lnhsingh

Base: mainHead: docs/langgraph-recursion-counter-handling


📝 Commits (2)

  • 37853c6 Expanding docs to include recursion counter access and proactive handling in graph-api
  • d3a0fbe Merge branch 'main' into docs/langgraph-recursion-counter-handling

📊 Changes

1 file changed (+329 additions, -0 deletions)

View changed files

📝 src/oss/langgraph/graph-api.mdx (+329 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/docs/pull/1166 **Author:** [@niilooy](https://github.com/niilooy) **Created:** 10/28/2025 **Status:** ✅ Merged **Merged:** 11/6/2025 **Merged by:** [@lnhsingh](https://github.com/lnhsingh) **Base:** `main` ← **Head:** `docs/langgraph-recursion-counter-handling` --- ### 📝 Commits (2) - [`37853c6`](https://github.com/langchain-ai/docs/commit/37853c63ca564be771965b3ac02e3ad151ac4e2d) Expanding docs to include recursion counter access and proactive handling in graph-api - [`d3a0fbe`](https://github.com/langchain-ai/docs/commit/d3a0fbe44fcbd69a9a15fb8867be53091220046f) Merge branch 'main' into docs/langgraph-recursion-counter-handling ### 📊 Changes **1 file changed** (+329 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/oss/langgraph/graph-api.mdx` (+329 -0) </details> ### 📄 Description ## 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 - [x] I have read the [contributing guidelines](README.md) - [x] I have tested my changes locally using `docs dev` - [x] All code examples have been tested and work correctly - [x] 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-17 17:22:12 -05:00
yindo closed this issue 2026-02-17 17:22:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/docs#1354