org.llm4s.zio

package org.llm4s.zio

Members list

Type members

Classlikes

An item of an agent's event stream: each of the run's events, then its result.

An item of an agent's event stream: each of the run's events, then its result.

Attributes

Source
AgentStreamItem.scala
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
trait AgentZ

ZIO wrapper for Agent.

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 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 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
Source
AgentZ.scala
Supertypes
class Object
trait Matchable
class Any
object AgentZ

Attributes

Companion
trait
Source
AgentZ.scala
Supertypes
class Object
trait Matchable
class Any
Self type
AgentZ.type
trait LLMClientZ

ZIO wrapper for LLMClient.

ZIO wrapper for LLMClient.

Blocking LLM calls are shifted to ZIO's blocking thread pool via ZIO.attemptBlockingInterrupt, keeping the fiber executor free. Interrupting the fiber (or a timeout) interrupts the provider thread, which is how llm4s providers are cancelled: they keep the interrupt and return Left(CancelledError). An exception thrown by a provider is a defect. LLMError is used directly as the error channel type — no wrapping needed.

Attributes

Companion
object
Source
LLMClientZ.scala
Supertypes
class Object
trait Matchable
class Any
object LLMClientZ

Attributes

Companion
trait
Source
LLMClientZ.scala
Supertypes
class Object
trait Matchable
class Any
Self type
LLMClientZ.type