ZIO wrapper for Agent.
Lifts every Result[AgentResult] into ZIO[Any, LLMError, AgentResult]. run and continueConversation start the turn on ZIO's blocking pool and then await it, so interrupting 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 a ZStream of its events (AgentStreamItem.Event), then its result (AgentStreamItem.Done); interrupting the stream cancels the turn as interrupting run does. Stopping early (take(n), runHead) 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 never dropped, and the run carries on.
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 fails the effect with that error, not as a defect.
Intentionally a thin wrapper: build the Agent with its tools, middleware (guardrails), handoffs and options through Agent.builder, or LLMClientZ.agent.
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any