langgraph
langgraph copied to clipboard
(WIP) Add support for early stopping in agent executor
Following https://github.com/langchain-ai/langgraph/issues/265, here we add support for early stopping (e.g., via max_iterations
or max_execution_time
) as in AgentExecutor.
WIP: looking for feedback on the general strategy for incorporating AgentExecutor's attributes, eventually including
-
return_intermediate_steps
-
max_iterations
-
max_execution_time
-
early_stopping_method
-
handle_parsing_errors
-
trim_intermediate_steps
Here I've added some to AgentState
, but it's unclear to me how to set defaults when they are not passed in by the caller on invoke, stream, etc. For example, even if I set iteration_count: int = 0
in AgentState, it gets set to 0 if not included in the input. Looking for suggestions on other ways to do this!
We support max_iterations natively in langgraph through the config key recursion_limit
:
app.invoke(..., {"recursion_limit": 15})
We support step_timeout
arg natively in langgraph, see step_timeout
constructor arg in Pregel/CompiledGraph. I don't think we need total_timeout
when we have step timeout.