OptionalreasonWhy the hook stopped the loop, reported back as AiCallResult.hookReason. Ignored unless stop is true.
OptionalstopWhen true, the loop ends after this round-trip: tool calls it requested are not executed, the call's outcome is STOPPED_BY_HOOK, and an onTurn callback is not consulted.
Return shape for
onIteration. Setstop: trueto end the loop after this round-trip, with an optionalreasonthe result reports ashookReason; return nothing (or an empty object) to continue.Example: ```javascript onIteration: (state) => state.iteration >= 3 ? { stop: true, reason: "three round-trips is enough" } : null, // returning nothing continues the loop ```