feat(FN-4388): complete remaining observability surfaces

Fusion-Task-Id: FN-4388
Fusion-Task-Lineage: 7497a0a1-5edb-4778-b339-118d1fd668f7
This commit is contained in:
Fusion
2026-05-13 22:33:42 -07:00
committed by gsxdsm
parent 444a076ff7
commit 8539a3dec0
11 changed files with 297 additions and 6 deletions

View File

@@ -367,6 +367,14 @@ The **Token Usage** panel in Agents view is derived from each agent's persisted
- `totalInputTokens`
- `totalOutputTokens`
### Cache-hit observability
Fusion exposes cache-hit metrics across logs, API, and CLI:
- **Structured logs:** `token-cache-metrics` channel emits per-persist records with `taskId`, `agentId`, `role`, `inputTokens`, `cachedTokens`, `cacheWriteTokens`, and computed `hitRatio`.
- **Agent API:** `GET /api/agents/:id/token-usage` returns `last24h`, `last7d`, and `allTime` window summaries for permanent agents.
- **CLI rollup:** run `pnpm fn:cache-stats` (or `pnpm fn:cache-stats --json`) for project-wide role totals plus per-permanent-agent cache-hit summaries.
For the current filtered/visible agent set, the panel shows:
- Aggregate input token total