org.llm4s.agent.events

Members list

Type members

Classlikes

object AgentEvents

The events an agent run sends, each an org.llm4s.agent.graph.EventType to match a StreamEvent with:

The events an agent run sends, each an org.llm4s.agent.graph.EventType to match a StreamEvent with:

agent.stream(threadId, "Explain monads") {
 case AgentEvents.TextDelta(d)          => print(d.text)
 case AgentEvents.ToolExecuted(t)       => println(s"${t.tool}: ${t.outcome} in ${t.duration}")
 case _                                 => ()
}

Durable (stored, replayed, no content): ModelCallCompleted, ToolExecuted, HandedOff, GuardrailBlocked. Live (current subscribers only): ModelCallStarted, TextDelta, ThinkingDelta, ToolCallStarted, ToolCallResult.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
final case class CallUsage(promptTokens: Int, completionTokens: Int, totalTokens: Int, thinkingTokens: Option[Int])

A model call's token usage, as plain numbers.

A model call's token usage, as plain numbers.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object CallUsage

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
CallUsage.type
final case class GuardrailBlock(guardrail: String, phase: GuardrailPhase)

A guardrail blocked the turn; the reason is on AgentStatus.Blocked, never in the log.

A guardrail blocked the turn; the reason is on AgentStatus.Blocked, never in the log.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Where a guardrail blocked the turn.

Where a guardrail blocked the turn.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class HandedOff(from: String, to: String)

The active agent changed from from to to.

The active agent changed from from to to.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class ModelCallCompleted(agent: String, model: String, attempts: Int, toolCalls: Int, usage: Option[CallUsage], estimatedCost: Option[Double])

agent's model call returned. attempts counts the calls its model wrappers made to the model, the last one succeeding; it is 0 when a model middleware answered without calling the model. usage and estimatedCost (USD) are the completion's, when the provider reported them.

agent's model call returned. attempts counts the calls its model wrappers made to the model, the last one succeeding; it is 0 when a model middleware answered without calling the model. usage and estimatedCost (USD) are the completion's, when the provider reported them.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class ModelCallStarted(agent: String, attempt: Int)

agent's model is being called; a higher attempt in the same task discards the earlier attempt's text.

agent's model is being called; a higher attempt in the same task discards the earlier attempt's text.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class TextDelta(attempt: Int, text: String)

A chunk of the model's answer, for attempt.

A chunk of the model's answer, for attempt.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class ThinkingDelta(attempt: Int, text: String)

A chunk of the model's thinking, for attempt.

A chunk of the model's thinking, for attempt.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class ToolCallResult(toolCallId: String, content: String, isError: Boolean)

The result the loop recorded for a call, as the model will see it.

The result the loop recorded for a call, as the model will see it.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class ToolCallStarted(toolCallId: String, tool: String, arguments: Value)

A tool call passed its argument checks and is about to run through the middleware chain.

A tool call passed its argument checks and is about to run through the middleware chain.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class ToolExecuted(agent: String, toolCallId: String, tool: String, duration: FiniteDuration, outcome: ToolExecutionOutcome)

One tool call's outcome; duration is the middleware chain's, zero for a call refused before it. tool is the called tool's name when the agent has that tool, else "<unknown>" (ToolLoop.UnknownTool): a name the model invented is not stored.

One tool call's outcome; duration is the middleware chain's, zero for a call refused before it. tool is the called tool's name when the agent has that tool, else "<unknown>" (ToolLoop.UnknownTool): a name the model invented is not stored.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ToolExecuted

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

How a tool call ended for the loop.

How a tool call ended for the loop.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all