SetUsage records cumulative input/output token counts under s.mu. The runtime stream goroutine and the persistence observer race on these fields without it.
(input, output int64)
| 552 | // The runtime stream goroutine and the persistence observer race on |
| 553 | // these fields without it. |
| 554 | func (s *Session) SetUsage(input, output int64) { |
| 555 | s.mu.Lock() |
| 556 | defer s.mu.Unlock() |
| 557 | s.InputTokens = input |
| 558 | s.OutputTokens = output |
| 559 | } |
| 560 | |
| 561 | // Usage returns a consistent snapshot of the cumulative input/output |
| 562 | // token counts. |
no test coverage detected