Lifts every Result[AgentResult] into F[AgentResult], raising an LLMError as LLMException in the error channel. run and continueConversation start the turn on a blocking thread and then await it, so cancelling the fiber cancels the turn itself (AgentRun.cancel) and returns once it has ended: its model call and tool calls are interrupted, and the thread is left for recover. recover and resume do the same through Agent.startRecover and Agent.startResume.
stream, streamResume and streamRecover run a turn as an fs2 stream of its events (AgentStreamItem.Event), then its result (AgentStreamItem.Done); interrupting the stream cancels the turn as cancelling run does. Stopping early (take(n)) also cancels the turn. A consumer too slow for the stream's buffer never holds the run up: it loses live events (text deltas, tool progress) and receives one StreamEvent.LiveGap with their count where they were dropped; durable events are kept, and the run carries on. A consumer that stops draining altogether fails the stream (and so cancels the turn) once more than Agent.StreamCapacity durable events wait, as the runtime disconnects a listener that far behind.
A model call that throws instead of returning Left ends the turn with a GraphError.NodeFailed whose cause is the LLMError the runtime made of the throwable; it is raised as an LLMException, not as the raw throwable.
Intentionally a thin wrapper: build the Agent with its tools, middleware (guardrails), handoffs and options through Agent.builder, or LLMClientIO.agent.
The events of run that eventType names - durable and live - decoded: events with EventHandlers.on(eventType)(identity); see the overload taking handlers.
The events of run that eventType names - durable and live - decoded: events with EventHandlers.on(eventType)(identity); see the overload taking handlers.
What handlers make of run's events: one element for each event a handler takes, in delivery order. It observes the run, through AgentRun.subscribe: it replays the run's durable events from its start and then follows it live, but misses the live events sent before the stream started - use stream to see every one. It ends after the run's terminal event, or once a run that ends without one has delivered its last event; the run's own outcome is not raised - await the run for it. Ending the stream early, or interrupting it, cancels its subscription only: the run carries on.
What handlers make of run's events: one element for each event a handler takes, in delivery order. It observes the run, through AgentRun.subscribe: it replays the run's durable events from its start and then follows it live, but misses the live events sent before the stream started - use stream to see every one. It ends after the run's terminal event, or once a run that ends without one has delivered its last event; the run's own outcome is not raised - await the run for it. Ending the stream early, or interrupting it, cancels its subscription only: the run carries on.
Handlers run on the stream, not on the subscription: a slow or throwing handler slows or fails the stream, never the run. A consumer too slow for the stream's buffer loses live events, as stream's does - a LiveGap, which a handler sees through otherwise. A subscription that disconnects, or a consumer that falls more than Agent.StreamCapacity durable events behind, raises LLMException.
events, with the events of every child run delegates to (design 4.47): the subscription is made with nested = true, so handlers also see each StreamEvent.Nested - matched with EventHandlers.onChild, or otherwise - after the parent's SubagentEvents.TaskStarted for its child. Nested events are live: a consumer too slow for the buffer loses them as a LiveGap.
events, with the events of every child run delegates to (design 4.47): the subscription is made with nested = true, so handlers also see each StreamEvent.Nested - matched with EventHandlers.onChild, or otherwise - after the parent's SubagentEvents.TaskStarted for its child. Nested events are live: a consumer too slow for the buffer loses them as a LiveGap.
One turn on threadId, as a stream: every event of the turn (Agent.stream), then Done(result). A refused start or a failed turn raises LLMException; so does a subscription that disconnects (its listener failed). A slow consumer loses live events and gets a StreamEvent.LiveGap instead; it does not cancel the run. Interrupting the stream cancels the turn and returns once it has ended, leaving the thread for recover.
One turn on threadId, as a stream: every event of the turn (Agent.stream), then Done(result). A refused start or a failed turn raises LLMException; so does a subscription that disconnects (its listener failed). A slow consumer loses live events and gets a StreamEvent.LiveGap instead; it does not cancel the run. Interrupting the stream cancels the turn and returns once it has ended, leaving the thread for recover.