Execution mode that loops until a successful result.
Calls the LLM, executes tool calls, and repeats until:
- The last message is an assistant response (success)
- The last message is a tool result with no errors (success)
- Max retry count is exceeded (error)
- Max runs is exceeded (error)
An assistant message that is narration only (see
LangChain.Message.narration?/1) is not a response. The model has said what
it is about to do without doing it, so the LLM is called again.
Options
:max_runs- Maximum LLM calls in one run before returning%LangChainError{type: "exceeded_max_runs"}. Default: 25. The count starts at 0 on everyLLMChain.run/2.:force_recurse— Whentrue, forces recursion even after a successful result. Default:false.
Usage
LLMChain.run(chain, mode: :until_success)