show token usage on per-agent web ui after each turn
This commit is contained in:
parent
ca86bcf4bd
commit
ce740483c6
6 changed files with 91 additions and 1 deletions
|
|
@ -196,6 +196,9 @@ struct StateSnapshot {
|
|||
/// the operator can see what they just switched to (and what's
|
||||
/// in flight). Mutable at runtime via `POST /api/model`.
|
||||
model: String,
|
||||
/// Token usage from the last completed turn. `null` until the
|
||||
/// first turn with usage data finishes.
|
||||
token_usage: Option<crate::events::TokenUsage>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
|
@ -232,6 +235,7 @@ async fn api_state(State(state): State<AppState>) -> axum::Json<StateSnapshot> {
|
|||
let inbox = recent_inbox(&state.socket, state.flavor()).await;
|
||||
let (turn_state, turn_state_since) = state.bus.state_snapshot();
|
||||
let model = state.bus.model();
|
||||
let token_usage = state.bus.last_usage();
|
||||
axum::Json(StateSnapshot {
|
||||
label: state.label.clone(),
|
||||
dashboard_port,
|
||||
|
|
@ -241,6 +245,7 @@ async fn api_state(State(state): State<AppState>) -> axum::Json<StateSnapshot> {
|
|||
turn_state,
|
||||
turn_state_since,
|
||||
model,
|
||||
token_usage,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue