[Bug]: Context usage ring exceeds 100% (up to +900%) because 'used' is cumulative API input tokens, not current context
Summary
Context usage ring shows >100% (up to +900%) on long agentic (ACP/Hermes) sessions because the ring's used value is the cumulative total of input tokens sent to the API across all calls, not the current context size. It is divided by the model context window, so it grows unboundedly past 100% and reads as a "context nearly full / overflow" state that is not real.
Environment
- AionUi v2.2.1 (Linux, Electron desktop)
- Agent: Hermes Agent via ACP (
hermes acp), modeldeepseek-v4-flash@api.deepseek.com(1,000,000 context)
Evidence
Stored acp_session.session_config for one long ACP conversation (backend session id a0bfa1e9-..., ~275 messages / ~144 tool calls):
"context_usage": {
"used": 9119095, // ring numerator → ring shows ~912%
"size": 1000000, // ring denominator (window, correct)
"_meta": {
"input_tokens": 9087457, // CUMULATIVE input across all API calls
"output_tokens": 31638,
"thought_tokens": 20565,
"cached_read_tokens": 8792576 // ~97% of input = re-sent history
}
}Ring math in the renderer (app.asar): percentage = total_tokens / context_limit * 100 with no clamp, and total_tokens = e.used. used comes from the ACP usage_update (used = estimated request pressure in the adapter) but the _meta.input_tokens shows the backend is filling used with cumulative provider usage, not current-context estimate. Two different AionUi conversations against the same backend end up with wildly different used (1.1M vs 9.1M) even when the actual current context is similar (~200-250K estimated).
Actual vs expected
- Actual: ring hits 100% mid-session then keeps climbing (+700-900%) for hours; warning (>70%) and danger (>90%) states are meaningless.
- Expected: ring should reflect current context occupancy (estimated request tokens for the live history) / window, and cap at 100% (e.g.
deepseek-v4-flashat ~230K/1M ≈ 23%).
Repro
- Run a long agentic session (Hermes ACP or any tool-heavy agent, 100+ tool calls).
- Watch the send-box context ring climb past 100% and keep rising each turn.
- Compare with the backend's actual live-context estimate (Hermes compresses only near ~80% of window; session still far from it).
Fix suggestion
- Use a current-context estimate (e.g. the ACP adapter's
usedfromUsageUpdatesized against live history) instead of provider cumulativeinput_tokens. - Clamp the ring percentage to 0-100, or display cumulative usage as a separate "tokens sent" metric.
Related: #1102, #3368 (feature requests for context usage display).
Source: iOfficeAI/AionUi