new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

LangChain · LangGraph · all subjects

error handling and fault tolerance

8 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Retry policies for nodes

LangGraph allows adding retry policies to nodes via the retry_policy parameter in add_node(). Provide a RetryPolicy object with configuration. By default, retry_on uses default_retry_on function which retries on most exceptions except ValueError, TypeError, ArithmeticError, ImportError, LookupError, NameError, SyntaxError, RuntimeError, ReferenceError, StopIteration, StopAsyncIteration, and OSError. For HTTP libraries like requests and httpx, it only retries on 5xx status codes.

Node timeouts in LangGraph

Use the timeout parameter with add_node() to limit how long a single async node invocation can run. Provide timeout in seconds or as a datetime.timedelta. Node timeouts are supported only for async nodes. When a node exceeds its timeout, LangGraph raises NodeTimeoutError which subclasses Python's TimeoutError. Timed-out attempts do not commit their buffered writes. If the node has a retry_policy that retries TimeoutError, the timed-out attempt is retried.

TimeoutPolicy for finer control

TimeoutPolicy can be used with the timeout parameter on add_node() for finer control over run and idle timeouts. Pass TimeoutPolicy(run_timeout=120, idle_timeout=30) to set both run and idle timeout limits independently. Requires langgraph>=1.2.

Node error handlers

The error_handler parameter on add_node() registers a function that runs after a node fails and all retries are exhausted. The handler receives the current state and a typed NodeError with failure context, and can route to a recovery branch via Command. Requires langgraph>=1.2.

Access drain state in a node

When graceful shutdown has been requested, runtime.drain_requested is True. Read this inside a node to skip expensive work before the next superstep boundary. runtime.drain_reason contains the reason string passed to request_drain(), or None if drain was not requested. Requires langgraph>=1.2.

Adjust node behavior based on retry attempts

Use runtime.executionInfo.nodeAttempt to determine the current retry attempt number and switch to a fallback after the first attempt fails. If nodeAttempt is greater than 1, you can use a fallback API. nodeAttempt defaults to 1 even without a retry policy.

Superstep transactionality and error handling

LangGraph executes nodes within supersteps, making the entire superstep transactional. If any parallel branch raises an exception, no updates from that superstep are applied to state. When using a checkpointer, results from successful nodes within a superstep are saved and don't repeat when resumed. Only failing branches are retried with a retry_policy.

GraphRecursionError exception handling

When recursion limit is exceeded, LangGraph raises GraphRecursionError. Catch and handle with try/except (Python) or try/catch (TypeScript). Import GraphRecursionError from langgraph.errors (Python) or @langchain/langgraph (TypeScript).

Give your agent this brain