Skip to main content

codetether_rlm/events/
completion.rs

1//! RLM completion record.
2
3use serde::{Deserialize, Serialize};
4use uuid::Uuid;
5
6use super::RlmOutcome;
7
8/// Terminal record for a single RLM invocation.
9#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct RlmCompletion {
11    pub trace_id: Uuid,
12    pub outcome: RlmOutcome,
13    pub iterations: usize,
14    pub subcalls: usize,
15    pub input_tokens: usize,
16    pub output_tokens: usize,
17    pub elapsed_ms: u64,
18    pub reason: Option<String>,
19    pub root_model: String,
20    #[serde(default, skip_serializing_if = "Option::is_none")]
21    pub subcall_model_used: Option<String>,
22}
23
24impl RlmCompletion {
25    /// output_tokens / input_tokens, 0.0 when input is zero.
26    pub fn compression_ratio(&self) -> f64 {
27        if self.input_tokens == 0 {
28            0.0
29        } else {
30            self.output_tokens as f64 / self.input_tokens as f64
31        }
32    }
33}