-
Notifications
You must be signed in to change notification settings - Fork 166
fix: allow null value for used field in UsageUpdate #605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -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<u64>, | ||||||||
|
Comment on lines
+253
to
+254
|
||||||||
| #[serde(skip_serializing_if = "Option::is_none")] | |
| pub used: Option<u64>, | |
| pub used: u64, |
Copilot
AI
Mar 1, 2026
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usedis now optional, but the doc comment still reads like it’s always present. Please update the field docs to clarify thatusedmay be omitted/null when the agent doesn’t provide token usage information (and whatNonemeans semantically).