# `Sagents.Modes.AgentExecution`

Standard sagents execution mode.

Replaces the separate `execute_chain_with_state_updates` and
`execute_chain_with_hitl` loops with a single composable pipeline.

## Pipeline

1. Call the LLM
2. Check for HITL interrupts (if HumanInTheLoop middleware present)
3. Execute tools
4. Propagate state updates from tool results
5. Check if target tool was called (if `until_tool` is set)
6. Loop if `needs_response` is 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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
