mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-17 23:27:56 +02:00
Retries were previously entirely in-memory: the attempt counter and backoff sleep happened inside run_with_retry/arun_with_retry without any checkpoint writes. If the process crashed mid-retry, the state was lost and the task would restart from attempt 0 on resume, effectively ignoring max_attempts across restarts. This change adds a RETRY special write channel. On each retryable failure, before sleeping, the retry loop persists (attempt_count, next_retry_timestamp) to the checkpoint via put_writes. On resume, the scratchpad restores these values so the retry loop continues from the correct attempt and honors the remaining backoff time. Key changes: - New RETRY constant in _constants.py and checkpoint serde/types - RETRY added to WRITES_IDX_MAP for checkpoint storage - PregelScratchpad gains retry_attempt/retry_ts fields - _scratchpad() in _algo.py extracts RETRY from pending_writes - _match_writes skips RETRY (like ERROR/INTERRUPT/RESUME) - output_writes returns early for RETRY (no stream output) - run_with_retry/arun_with_retry accept put_writes callback, restore attempt state from scratchpad, persist before sleep - Runner passes put_writes to retry functions https://claude.ai/code/session_01768mrKrVCCtXdJgRNFdWrb