Skip to content

Commit 374e510

Browse files
authored
Upper bound on number of iterations (#754)
Some custom agents might continue to iterate until they find the correct answer, getting stuck on loops that generate request after request and are really expensive for the end user. Putting an upper bound for the number of iterations by default controls this and can be explicitly tweaked by the user if necessary. Co-authored-by: Francisco Ingham <>
1 parent 28efbb0 commit 374e510

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

langchain/agents/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class AgentExecutor(Chain, BaseModel):
199199
agent: Agent
200200
tools: List[Tool]
201201
return_intermediate_steps: bool = False
202-
max_iterations: Optional[int] = None
202+
max_iterations: Optional[int] = 15
203203
early_stopping_method: str = "force"
204204

205205
@classmethod

0 commit comments

Comments
 (0)