fix(session): tolerate negative token counts in stored parts (#26620)

This commit is contained in:
Kit Langton 2026-05-09 22:10:44 -04:00 committed by GitHub
commit c6e6bdf59f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 120 additions and 23 deletions

View file

@ -270,13 +270,13 @@ export const StepFinishPart = Schema.Struct({
snapshot: Schema.optional(Schema.String),
cost: Schema.Finite,
tokens: Schema.Struct({
total: Schema.optional(NonNegativeInt),
input: NonNegativeInt,
output: NonNegativeInt,
reasoning: NonNegativeInt,
total: Schema.optional(Schema.Finite),
input: Schema.Finite,
output: Schema.Finite,
reasoning: Schema.Finite,
cache: Schema.Struct({
read: NonNegativeInt,
write: NonNegativeInt,
read: Schema.Finite,
write: Schema.Finite,
}),
}),
})
@ -554,13 +554,13 @@ export const Assistant = Schema.Struct({
summary: Schema.optional(Schema.Boolean),
cost: Schema.Finite,
tokens: Schema.Struct({
total: Schema.optional(NonNegativeInt),
input: NonNegativeInt,
output: NonNegativeInt,
reasoning: NonNegativeInt,
total: Schema.optional(Schema.Finite),
input: Schema.Finite,
output: Schema.Finite,
reasoning: Schema.Finite,
cache: Schema.Struct({
read: NonNegativeInt,
write: NonNegativeInt,
read: Schema.Finite,
write: Schema.Finite,
}),
}),
structured: Schema.optional(Schema.Any),