Featured image of post LangGraph 1.2.0 Introduces set_node_defaults for Unified Node Policy Configuration

LangGraph 1.2.0 Introduces set_node_defaults for Unified Node Policy Configuration

LangGraph 1.2.0 adds set_node_defaults to batch-configure retry, timeout, cache, and error handling for all nodes.

LangGraph 1.2.0 Released: Unified Node Policy Configuration via set_node_defaults

LangGraph has released version 1.2.0, introducing set_node_defaults—a new method that enables batch configuration of default runtime policies for all nodes in a graph, drastically reducing boilerplate code and maintenance overhead. This method must be called before compile() and applies to all regular nodes in the current graph.

Core Functionality and Technical Details

set_node_defaults is a chainable method on the StateGraph builder, supporting four default policy types:

  • retry_policy: Node retry policy for handling temporary failures
  • timeout: Node execution timeout policy to prevent indefinite hanging
  • cache_policy: Node result caching policy for improved efficiency on repeated calls
  • error_handler: Node fallback error handling function for centralized exception capture

The key priority rule is: policies passed directly to add_node override global defaults. This allows developers to set shared baseline policies for most nodes while customizing only exceptional ones.

Scope of application is clearly differentiated:

  • retry_policy and timeout apply to all nodes, including error handler nodes
  • cache_policy and error_handler apply only to regular business nodes; they do not apply to the error handler itself, preventing infinite recursion when error handlers encounter errors
  • Subgraphs do not automatically inherit parent graph defaults and must call set_node_defaults independently

Use Cases and Code Example

In production-grade Agent development, graphs often contain dozens of nodes (commonly involving LLM calls and tool invocations). Previously, each add_node required repetitive parameter passing for retry_policy, timeout, etc.—inflating boilerplate code and forcing manual edits across nodes when baseline policies changed.

With the new API, code structure is significantly simplified:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
builder = (
    StateGraph(State)
    .set_node_defaults(
        retry_policy=RetryPolicy(max_attempts=3),
        timeout=TimeoutPolicy(run_timeout=30),
        error_handler=global_error_handler,
    )
    .add_node("node_a", node_a)
    .add_node("node_b", node_b, retry_policy=RetryPolicy(max_attempts=5))
    .add_edge(START, "node_a")
)

Here, node_a uses the global default of 3 retry attempts, while node_b overrides this with 5 attempts—flexible coexistence of global defaults and per-node customization.

Practical Recommendations

  • Adopt immediately if: Your project involves medium-to-large Agent graphs (e.g., 5+ nodes) where most nodes share identical error-handling requirements
  • Wait before upgrading if: Your current project runs stably on LangGraph 1.1 or earlier with very few nodes (≤3) or highly divergent policy needs; note this API is only available starting at version 1.2.0, and is absent in earlier versions

Final Thoughts

set_node_defaults elevates runtime policy management from the node level to the graph level, reflecting LangGraph’s ongoing refinement for production readiness. Though not a paradigm-shifting change, it substantially improves developer experience and long-term maintainability by eliminating repetitive configuration patterns.