agent ctx-badge: seed Bus::last_usage from latest turn_stats row on startup
This commit is contained in:
parent
8a3e8bfb7f
commit
f827187341
4 changed files with 47 additions and 0 deletions
|
|
@ -378,6 +378,15 @@ impl Bus {
|
|||
self.emit(LiveEvent::ModelChanged { model: value });
|
||||
}
|
||||
|
||||
/// Seed `last_usage` at startup without emitting a SSE event.
|
||||
/// Used by the bin entrypoints to backfill from the most recent
|
||||
/// `turn_stats` row so the per-agent web UI's `ctx-badge` paints
|
||||
/// real numbers on cold load instead of staying empty until the
|
||||
/// next turn finishes.
|
||||
pub fn seed_usage(&self, usage: TokenUsage) {
|
||||
*self.last_usage.lock().unwrap() = Some(usage);
|
||||
}
|
||||
|
||||
/// Record the latest token usage from a completed turn.
|
||||
pub fn record_usage(&self, usage: TokenUsage) {
|
||||
*self.last_usage.lock().unwrap() = Some(usage);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue