ConversationObserver

An AgentObserver that is also told what the calls send and get back: the request a model is sent, its answer, the input of a tool and its result. Use it to record the conversation in a trace, as OtlpObserver and OpenTelemetryObserver of telar-otel do with recordContent = true:

val log = object : ConversationObserver {
override fun onModelCallResponse(call: ObservedModelCall, response: ChatResponse) {
println("${call.caller}: ${response.message.text}")
}
}

The conversation can hold personal data, such as what the users of an app wrote, so only an observer that implements this interface gets it. The rules of AgentObserver hold, and:

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun onCheckpointSaved(run: ObservedRun, step: Int, nextNodes: List<String>)
Link copied to clipboard
open fun onEdgeCompleted(edge: ObservedEdge, targets: List<String>)
Link copied to clipboard
open fun onEdgeFailed(edge: ObservedEdge, cause: Throwable)
Link copied to clipboard
open fun onEdgeStarted(edge: ObservedEdge)
Link copied to clipboard

The model of call answered, with the tokens its provider reported, or null when it reported none.

Link copied to clipboard

The model of call failed with cause, or the call was cancelled.

Link copied to clipboard

The model of call is sent request. Called right after onModelCallStarted.

Link copied to clipboard

The model of call answered with response. Called right before onModelCallCompleted.

Link copied to clipboard

call asks its model. A try of a node with a retry asks again, as a new call.

Link copied to clipboard
Link copied to clipboard
open fun onNodeFailed(node: ObservedNode, cause: Throwable)
Link copied to clipboard
Link copied to clipboard
open fun onNodeProgress(node: ObservedNode, value: Any)
Link copied to clipboard
open fun onNodeRetry(node: ObservedNode, attempt: Int, cause: Throwable, pause: Duration)
Link copied to clipboard
open fun onNodeStarted(node: ObservedNode)
Link copied to clipboard
Link copied to clipboard
open fun onRunFailed(run: ObservedRun, cause: Throwable)
Link copied to clipboard
open fun onRunInterrupted(run: ObservedRun, nextNodes: List<String>)
Link copied to clipboard
open fun onRunStarted(run: ObservedRun)
Link copied to clipboard
open fun onStepCompleted(run: ObservedRun, step: Int, nodes: List<String>, nextNodes: List<String>)
Link copied to clipboard
open fun onToolCallCompleted(call: ObservedToolCall, isError: Boolean)

The tool of call returned a result for the model. isError is true when the tool failed, or the call named no tool or had an input that does not fit, which the model is told as well.

Link copied to clipboard

call ended without a result: it was cancelled, the tool paused the run with interrupt, or it threw an error that ends the run, such as an OutOfMemoryError.

Link copied to clipboard
open fun onToolCallInput(call: ObservedToolCall, toolCall: ToolCall)

The model's toolCall is what the tool of call runs on. An input that is not JSON is in ToolCall.invalidInput. Called right after onToolCallStarted.

Link copied to clipboard

The tool of call returned result for the model. Called right before onToolCallCompleted.

Link copied to clipboard

call runs its tool.