Sagents.Modes.AgentExecution (Sagents v0.4.0)
Copy MarkdownStandard sagents execution mode.
Replaces the separate execute_chain_with_state_updates and
execute_chain_with_hitl loops with a single composable pipeline.
Pipeline
- Call the LLM
- Check for HITL interrupts (if HumanInTheLoop middleware present)
- Execute tools
- Propagate state updates from tool results
- Check if target tool was called (if
until_toolis set) - Loop if
needs_responseis true, or error if until_tool contract violated
Options
:middleware— Agent's middleware list (for HITL checking):should_pause?— Zero-arity function for infrastructure pause:max_runs— Maximum LLM calls (default: 50):until_tool— Tool name (string) or list of tool names. When set, the mode will return{:ok, chain, tool_result}when the target tool is called, or{:error, chain, %LangChainError{}}if the LLM stops without calling it.