You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(ui): correctly display token usage across sessions (kagent-dev#1509)
When testing kagent-dev#1500, I struggled to visually demonstrate the affect of
the duplicated session history (aka context bloat) when chatting with
agents. The current implementation of "Usage" within the UI (introduced
in kagent-dev#679) uses `Math.max` independently per field (`total`, `prompt`,
`completion`) across all tasks in a session. This produces incoherent
values where `total` does not necessarily match `prompt` + `completion`,
since each field[^1] (most notably `prompt`) can peak during differing
tasks. And, it doesn't correctly update to reflect usage across multiple
API calls in a multi-turn conversation. All we see is which API call has
the greatest of each type of token usage.
This PR addresses those shortcomings by:
- Updating the existing token usage display to reflect session total
across multiple turns
- Show per-call token usage tooltip on tool call cards and text messages
[^1]: not 100% certain here but I think that fields other than input
could also peak at different levels within cached prompt scenarios.
Signed-off-by: Brian Fox <878612+onematchfox@users.noreply.github.com>
0 commit comments