mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-26 17:42:24 +02:00
This PR implements task/node-level timeouts. Since python has a terrible multi-processing model, we make two concessions: - we only support for async functions/nodes. Sync nodes with a timeout raise an error at compile time - we implement this with asyncio wait_for in the async path. Each timed attempt is wrapped in _retry.py, and the timer is reset on each node-level retry. When the deadline is exceeded LangGraph raises NodeTimeoutError, clears buffered writes, and prevents any late writes or child-task scheduling from leaking past the timeout via _TimedAttemptScope. The design also adds a timed-attempt observer hook (CONFIG_KEY_TIMED_ATTEMPT_OBSERVER) that emits start/finish events with identifiers and deadlines. This means that if you have an orchestrating process starting a worker process, it can listen to start/end events and hard-kill the process to enforce a timeout if there is a deadlock. --------- Co-authored-by: Will Fu-Hinthorn <will@langchain.dev>