Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ impl SessionInfoUpdate {
#[non_exhaustive]
pub struct UsageUpdate {
/// Tokens currently in context.
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used is now optional, but the doc comment still reads like it’s always present. Please update the field docs to clarify that used may be omitted/null when the agent doesn’t provide token usage information (and what None means semantically).

Suggested change
/// Tokens currently in context.
/// Tokens currently in context.
///
/// This field is optional and may be omitted/`null` if the agent does not provide
/// token usage information for this update. When `None`, the token usage is
/// unknown, not necessarily zero.

Copilot uses AI. Check for mistakes.
pub used: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub used: Option<u64>,
Comment on lines +253 to +254
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By changing used from u64 to Option<u64>, the generated unstable JSON Schema for UsageUpdate will change (nullable + no longer required). Please regenerate and commit the updated schema/schema.unstable.json (and any generated docs/metadata that depend on it) so the repository’s published schema stays in sync with the Rust types.

Suggested change
#[serde(skip_serializing_if = "Option::is_none")]
pub used: Option<u64>,
pub used: u64,

Copilot uses AI. Check for mistakes.
/// Total context window size in tokens.
pub size: u64,
/// Cumulative session cost (optional).
Expand All @@ -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<u64>, size: u64) -> Self {
Self {
used,
used: used.into_option(),
size,
Comment on lines 252 to 275
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change fixes deserialization of used: null, but there’s no test coverage for UsageUpdate’s (de)serialization behavior. Please add unit tests (under #[cfg(feature = "unstable_session_usage")]) that cover at least: {used: null} -> used == None, {} (missing used) behavior if supported, and serialization behavior when used is None vs Some (especially with skip_serializing_if).

Copilot uses AI. Check for mistakes.
cost: None,
meta: None,
Expand Down
Loading