mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-17 21:25:46 +02:00
Merge pull request #1118 from langchain-ai/nc/24jul/fix-recursion-limit-thread
Fix recursion limit considering steps taken in previous runs on same thread
This commit is contained in:
@@ -102,6 +102,7 @@ class PregelLoop:
|
||||
checkpoint_pending_writes: List[PendingWrite]
|
||||
|
||||
step: int
|
||||
stop: int
|
||||
status: Literal[
|
||||
"pending", "done", "interrupt_before", "interrupt_after", "out_of_steps"
|
||||
]
|
||||
@@ -203,7 +204,7 @@ class PregelLoop:
|
||||
return False
|
||||
|
||||
# check if iteration limit is reached
|
||||
if self.step > self.config["recursion_limit"]:
|
||||
if self.step > self.stop:
|
||||
self.status = "out_of_steps"
|
||||
return False
|
||||
|
||||
@@ -419,6 +420,7 @@ class SyncPregelLoop(PregelLoop, ContextManager):
|
||||
)
|
||||
self.status = "pending"
|
||||
self.step = self.checkpoint_metadata["step"] + 1
|
||||
self.stop = self.step + self.config["recursion_limit"] + 1
|
||||
|
||||
return self
|
||||
|
||||
@@ -497,6 +499,7 @@ class AsyncPregelLoop(PregelLoop, AsyncContextManager):
|
||||
)
|
||||
self.status = "pending"
|
||||
self.step = self.checkpoint_metadata["step"] + 1
|
||||
self.stop = self.step + self.config["recursion_limit"] + 1
|
||||
|
||||
return self
|
||||
|
||||
|
||||
Reference in New Issue
Block a user