From 5eacc99146f5ce79bbbeb77eed1d1190ba37ddf3 Mon Sep 17 00:00:00 2001 From: iris Date: Sun, 21 Jun 2026 21:27:28 +0200 Subject: [PATCH] =?UTF-8?q?fix(dashboard):=20ctx=C2=B7Nk=20card=20badge=20?= =?UTF-8?q?showed=200k=20=E2=80=94=20use=20context=5Ftokens()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /api/dashboard-state reported ctx_tokens from raw ctx_usage.input_tokens, which is only the *uncached* input. With prompt caching the bulk of the prompt is cache-read, so input_tokens is ~0 and every SW4RM card showed 'ctx·0k'. Use ctx_usage.context_tokens() (input + cache-read + cache-creation = the real window size) to match the agent page (ships the full ctx_usage) and turn.rs's cache-TTL check. Doc comment updated. --- hive-ag3nt/src/web_ui.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hive-ag3nt/src/web_ui.rs b/hive-ag3nt/src/web_ui.rs index 113da430..f2835c1d 100644 --- a/hive-ag3nt/src/web_ui.rs +++ b/hive-ag3nt/src/web_ui.rs @@ -664,8 +664,9 @@ struct DashboardState { /// `None` when no status is set. #[serde(skip_serializing_if = "Option::is_none")] status_set_at: Option, - /// Input token count from the most recent completed turn (`ctx_usage.input_tokens`). - /// `None` until the first turn finishes. + /// Full context-window size from the most recent completed turn + /// (`ctx_usage.context_tokens()` = input + cache-read + cache-creation). + /// `None` until the first turn finishes. Drives the `ctx·Nk` card badge. #[serde(skip_serializing_if = "Option::is_none")] ctx_tokens: Option, /// Effective context-window budget for the current model. Same @@ -714,7 +715,12 @@ async fn api_dashboard_state(State(state): State) -> axum::Json