mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
feat: add max_depth
This commit is contained in:
@@ -543,7 +543,11 @@ class LLM:
|
|||||||
agent = None
|
agent = None
|
||||||
task = None
|
task = None
|
||||||
|
|
||||||
while caller_frame:
|
# Add a maximum depth to prevent infinite loops
|
||||||
|
max_depth = 100 # Reasonable limit for call stack depth
|
||||||
|
current_depth = 0
|
||||||
|
|
||||||
|
while caller_frame and current_depth < max_depth:
|
||||||
if "self" in caller_frame.f_locals:
|
if "self" in caller_frame.f_locals:
|
||||||
caller_self = caller_frame.f_locals["self"]
|
caller_self = caller_frame.f_locals["self"]
|
||||||
if isinstance(caller_self, AgentExecutorProtocol):
|
if isinstance(caller_self, AgentExecutorProtocol):
|
||||||
@@ -551,6 +555,7 @@ class LLM:
|
|||||||
task = caller_self.task
|
task = caller_self.task
|
||||||
break
|
break
|
||||||
caller_frame = caller_frame.f_back
|
caller_frame = caller_frame.f_back
|
||||||
|
current_depth += 1
|
||||||
|
|
||||||
return agent, task
|
return agent, task
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user