diff --git a/src/client.rs b/src/client.rs index dada5581..ec37f265 100644 --- a/src/client.rs +++ b/src/client.rs @@ -250,7 +250,8 @@ impl SessionInfoUpdate { #[non_exhaustive] pub struct UsageUpdate { /// Tokens currently in context. - pub used: u64, + #[serde(skip_serializing_if = "Option::is_none")] + pub used: Option, /// Total context window size in tokens. pub size: u64, /// Cumulative session cost (optional). @@ -268,9 +269,9 @@ pub struct UsageUpdate { #[cfg(feature = "unstable_session_usage")] impl UsageUpdate { #[must_use] - pub fn new(used: u64, size: u64) -> Self { + pub fn new(used: impl IntoOption, size: u64) -> Self { Self { - used, + used: used.into_option(), size, cost: None, meta: None,