langgraph icon indicating copy to clipboard operation
langgraph copied to clipboard

(WIP) Add support for early stopping in agent executor

Open ccurme opened this issue 10 months ago • 2 comments

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!

ccurme avatar Apr 02 '24 20:04 ccurme

We support max_iterations natively in langgraph through the config key recursion_limit:

app.invoke(..., {"recursion_limit": 15})

nfcampos avatar Apr 02 '24 22:04 nfcampos

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.

nfcampos avatar Apr 02 '24 22:04 nfcampos