#[non_exhaustive]pub enum EventKind {
Show 25 variants
PromptStarted {
model: String,
messages_in: usize,
},
PromptCompleted {
model: String,
tokens_in: Option<u64>,
tokens_out: Option<u64>,
cached_tokens_in: Option<u64>,
reasoning_tokens: Option<u64>,
cost_usd: Option<f64>,
finish_reason: Option<String>,
response_id: Option<String>,
previous_response_id: Option<String>,
time_to_first_token_ms: Option<u64>,
duration_ms: Option<u64>,
},
PromptFailed {
model: String,
error_class: ErrorClass,
message: String,
retriable: bool,
provider_error_code: Option<String>,
http_status: Option<u16>,
},
ToolInvoked {
tool_name: String,
provider_call_id: Option<String>,
call_id: String,
args_json: String,
truncated: bool,
},
ToolCompleted {
tool_name: String,
provider_call_id: Option<String>,
call_id: String,
result: String,
truncated: bool,
duration_ms: Option<u64>,
},
ToolFailed {
tool_name: String,
call_id: String,
error_class: ErrorClass,
message: String,
},
ToolSkipped {
tool_name: String,
call_id: String,
reason: String,
},
ToolTerminated {
tool_name: String,
call_id: String,
reason: String,
},
ToolHostedInvoked {
tool_name: String,
provider_call_id: Option<String>,
call_id: String,
response_id: Option<String>,
args_json: String,
truncated: bool,
},
ToolHostedCompleted {
tool_name: String,
provider_call_id: Option<String>,
call_id: String,
response_id: Option<String>,
status: Option<String>,
result: String,
truncated: bool,
duration_ms: Option<u64>,
},
ContextSampled {
message_count: usize,
byte_size: usize,
token_estimate: Option<u64>,
},
ContextCompacted {
evicted_count: usize,
evicted_bytes: usize,
carry_over: bool,
summary_bytes: usize,
},
MemoryDemoted {
demoted_count: usize,
tags: Vec<String>,
},
MemoryFrameWritten {
frame_kind: String,
frame_count_after: Option<u64>,
bytes_written: usize,
},
ComposeKernelStart {
kernel_id: String,
skills_registered: Option<usize>,
tools_registered: Option<usize>,
},
ComposeKernelShutdown {
kernel_id: String,
reason: String,
},
ComposeLoopIteration {
kernel_id: String,
iteration: u64,
skill_id: Option<String>,
confidence: Option<f64>,
},
ComposeSkillResolved {
kernel_id: String,
skill_id: String,
applies: bool,
delta: Option<f64>,
confidence: Option<f64>,
},
ComposeRetryAttempt {
kernel_id: String,
target: String,
attempt: u64,
classification: String,
},
ComposeRecovery {
kernel_id: String,
reason: String,
recovered: bool,
},
ResponseSessionStarted {
model: String,
session_id: String,
},
ResponseTurnStarted {
session_id: String,
previous_response_id: Option<String>,
},
ResponseTurnCompleted {
session_id: String,
response_id: String,
previous_response_id: Option<String>,
status: String,
tokens_in: Option<u64>,
tokens_out: Option<u64>,
hosted_tool_calls: usize,
duration_ms: Option<u64>,
},
ResponseSessionEnded {
session_id: String,
reason: String,
},
EvalReport {
report_id: String,
dataset: String,
metric: String,
value: f64,
ci_low: Option<f64>,
ci_high: Option<f64>,
baseline_value: Option<f64>,
delta: Option<f64>,
verdict: Option<String>,
sample_size: Option<u64>,
},
}Expand description
Payload variants. Tagged on the wire as "kind": "<dotted.name>".
New variants are additive; rename or remove is a breaking change requiring
a bump of SCHEMA_VERSION.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
PromptStarted
A prompt is about to be sent to the model provider.
Fields
PromptCompleted
A prompt finished; the model returned a completion response.
Fields
model: StringModel name as reported by the provider response (may differ from the requested model for routed providers).
previous_response_id: Option<String>Server-side chain ancestor when the producer is on a stateful
endpoint (e.g. OpenAI’s Responses API). None for one-shot
Chat Completions or the first turn of a chain. Populated by
crate::TelemetryHook::with_previous_response_id_resolver or
by producer crates emitting the kind directly.
PromptFailed
A prompt failed to complete successfully.
Fields
error_class: ErrorClassClassification of the error.
ToolInvoked
A tool is about to be invoked.
Fields
truncated: booltrue if args_json was truncated to
PAYLOAD_TRUNCATE_BYTES.
ToolCompleted
A tool finished executing.
Fields
truncated: booltrue if result was truncated to PAYLOAD_TRUNCATE_BYTES.
ToolFailed
A tool failed to complete its execution.
Fields
error_class: ErrorClassHigh-level classification of the failure.
ToolSkipped
A previously-ToolInvoked call was skipped by a gating hook before
the tool body ran. Pairs by call_id and closes the
tool.invoked/tool.completed gap that would otherwise leave the
invoke event orphaned.
Fields
ToolTerminated
A previously-ToolInvoked call triggered a hook-driven termination
of the agent loop. Pairs by call_id.
Fields
ToolHostedInvoked
A provider-native hosted tool was invoked. Hosted tools (OpenAI
Responses web_search / file_search / computer_use /
code_interpreter, future Anthropic/Google equivalents) run inside
the provider’s infrastructure rather than in the Rig agent loop, so
PromptHook::on_tool_call never fires for them. Producers wire this
variant from a streaming-chunk tap or session decorator.
Fields
tool_name: StringProvider-native hosted tool name (e.g. "web_search",
"file_search", "computer_use", "code_interpreter").
provider_call_id: Option<String>Provider-supplied call ID for the hosted invocation, when surfaced by the provider stream.
call_id: StringStable correlation ID chosen by the producer so the matching
tool.hosted_completed can be paired.
args_json: StringJSON-encoded arguments visible to the producer (possibly
truncated; see truncated). May be empty for providers that
do not expose hosted-tool inputs in the stream.
truncated: booltrue if args_json was truncated to
PAYLOAD_TRUNCATE_BYTES.
ToolHostedCompleted
A provider-native hosted tool finished. Pairs with
EventKind::ToolHostedInvoked by call_id.
Fields
status: Option<String>Provider-reported status (e.g. "completed", "failed"),
when surfaced. Free-form string per provider.
result: StringHosted result text or JSON (possibly truncated). May be empty for providers that do not surface hosted-tool outputs in the stream beyond the status.
truncated: booltrue if result was truncated to PAYLOAD_TRUNCATE_BYTES.
ContextSampled
The active context was sampled (typically on ConversationMemory::load).
Fields
ContextCompacted
A compactor fired, replacing some evicted history with a summary artifact.
Fields
MemoryDemoted
A demotion hook moved messages to long-term storage.
MemoryFrameWritten
A frame was written to the long-term store.
Fields
ComposeKernelStart
A rig-compose kernel became active for a conversation.
Fields
ComposeKernelShutdown
A rig-compose kernel stopped processing.
Fields
ComposeLoopIteration
One iteration of a rig-compose agent/kernel loop began.
Fields
ComposeSkillResolved
A rig-compose skill resolution completed.
Fields
ComposeRetryAttempt
A retry attempt occurred in a rig-compose dispatch or recovery path.
rig-tap does not emit this variant itself: the
[crate::DispatchObserveHook] only observes the lifecycle hooks
surfaced by rig-compose and rig-compose does not currently expose
a per-tool retry hook. Producers with their own retry policy (custom
skills, transports, or higher-level orchestrators) should emit this
variant directly via crate::emit_kind so consumers receive a
consistent shape.
Fields
ComposeRecovery
A rig-compose recovery path completed.
Fields
ResponseSessionStarted
A stateful provider session opened. Producers wrap a long-lived session (today: OpenAI Responses WebSocket) and emit this on connect.
Fields
ResponseTurnStarted
A turn began inside a stateful provider session. Producers emit this when the session enqueues a new server-side response.
Fields
ResponseTurnCompleted
A turn finished inside a stateful provider session. Pairs with the
most recent response.turn_started by session_id.
Fields
hosted_tool_calls: usizeNumber of hosted-tool invocations observed during this turn.
Each hosted call is also emitted individually via
EventKind::ToolHostedInvoked / EventKind::ToolHostedCompleted.
ResponseSessionEnded
A stateful provider session closed. Producers emit this on the
underlying close handshake, on a provider response.failed, or on
any session-fatal transport error.
Fields
EvalReport
One evaluation metric from a retrieval/RAG eval report. Producers
emit one event per (report_id, dataset, metric) triple so
consumers can filter and aggregate via the rig_tap.* scalars
without parsing the JSON envelope. Pairs naturally with the
MultiReport / ReportDiff summaries surfaced by
rig-retrieval-evals, but the variant is producer-agnostic: any
crate emitting metric verdicts on the same tracing target can
reuse it.
Fields
report_id: StringStable identifier for the report run (e.g. a commit SHA, a harness invocation id, or a wall-clock-named run).
dataset: StringDataset / qrels label the metric was computed against
(e.g. "beir/scifact", "internal/v3").
baseline_value: Option<f64>Baseline value the report was compared against, when a
ReportDiff is being emitted.
delta: Option<f64>Signed delta vs baseline_value, when a diff is being
emitted. Positive = improvement for higher-is-better metrics.
Implementations§
Source§impl EventKind
impl EventKind
Sourcepub fn discriminant(&self) -> &'static str
pub fn discriminant(&self) -> &'static str
Returns the wire kind discriminant for this event.
Sourcepub fn scalar_fields(&self) -> ScalarFields<'_>
pub fn scalar_fields(&self) -> ScalarFields<'_>
Extract the per-variant scalar correlation fields that
crate::emit() surfaces directly on the tracing event so that
OpenTelemetry collectors and log indexers can route on them without
parsing the JSON event blob.
Absent fields are returned as "" rather than Option<&str>
because tracing 0.1’s static-field model does not accept
Option<&str> as a Value. Consumers should filter
rig_tap.<field> != "" to detect presence.
Returns true if the event is part of the prompt lifecycle (prompt.started, prompt.completed, prompt.failed).
Returns true if the event is part of the tool lifecycle
(tool.invoked, tool.completed, tool.failed, tool.skipped, tool.terminated,
tool.hosted_invoked, tool.hosted_completed).
Returns true if this event indicates a failure in a prompt or tool call.
Returns true if the event is part of the stateful response-session
lifecycle (response.session_started, response.turn_started,
response.turn_completed, response.session_ended).
Returns true if the event is related to memory and context management.
Returns true if the event is related to a rig-compose kernel or agent loop.
Returns true if the event is an evaluation report metric
(eval.report).
Sourcepub fn tool_call_id(&self) -> Option<&str>
pub fn tool_call_id(&self) -> Option<&str>
Extracts the stable call_id for tool events, if present.