AgentRunEnded

org.llm4s.trace.TraceEvent.AgentRunEnded
See theAgentRunEnded companion object
final case class AgentRunEnded extends TraceEvent

An agent run ended. Emitted once per run, from the run's own final state, by the agent's tracing; it carries the turn's conversation for backends that record it (Langfuse turns it into a trace with one span per message). A blocked turn has been removed from the thread by then, so a blocked run carries no messages.

Value parameters

agent

the agent active when the run ended

messages

this turn's messages, from its user message on; empty when blocked, cancelled, timed out or failed. Not included in toJson, which stays a flat summary.

parentRunId

for a delegated child run, the parent run that started it; None for a top-level run

parentThreadId

for a delegated child run, the thread of the parent whose tool call started it; None for a top-level run

provider

the canonical id of the provider of the run's model calls (the first call's, when they used several), when its client reported one; OpenTelemetry's gen_ai.provider.name

runId

this run

span

the run's own span (design 4.58): its context, its parent - a child run's is the task tool call that started it, a continued run's the context it continued - and when the run started

status

completed, suspended, step_limit_reached, blocked:<guardrail>, cancelled, timed_out or failed

threadId

the conversation's thread; backends use it as the session

usage

this run's own token usage and cost, per model: the model calls the run made, never the thread's earlier runs, so a backend can report it per run (as OpenTelemetry's per-operation gen_ai.usage.*) without double counting

Attributes

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

Members list

Value members

Concrete methods

def eventType: String
def toJson: Value
def withAgent(agent: String): AgentRunEnded
def withMessages(messages: Seq[Message]): AgentRunEnded
def withParentRunId(parentRunId: String): AgentRunEnded
def withParentRunId(parentRunId: Option[String]): AgentRunEnded
def withParentThreadId(parentThreadId: String): AgentRunEnded
def withParentThreadId(parentThreadId: Option[String]): AgentRunEnded
def withProvider(provider: Option[ProviderId]): AgentRunEnded
def withRunId(runId: String): AgentRunEnded
def withSpan(span: Option[TraceSpan]): AgentRunEnded
def withStatus(status: String): AgentRunEnded
def withThreadId(threadId: String): AgentRunEnded
def withTimestamp(timestamp: Instant): AgentRunEnded

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product