agent-zero/plugins/_context_window
Alessandro 298cb2c05d
Some checks are pending
Build And Publish Docker Images / plan (push) Waiting to run
Build And Publish Docker Images / build (push) Blocked by required conditions
Speed up chat loading and guard selector refresh races
Run model/profile, context-usage and goal display refreshes independently
of snapshot rendering so chat switches do not wait for their API calls.

Guard refreshes and save completions by request sequence and selected chat.
Pending saves still finish for their original chat, while late responses
cannot replace the current selector state or finish a newer loading cycle.
Add deterministic pending-request and save-race regressions and update
the owning plugin contracts.

Validation: 94 focused tests passed for the loading change, followed by
47 focused tests after the model/profile race fixes. Live checks at
localhost:32081 covered delayed API responses, rapid chat switching,
late profile/preset/clear saves, and desktop/mobile behavior.
2026-10-10 14:10:35 +02:00
..
api Add context window display controls and price currency selection 2026-10-07 23:31:54 +02:00
extensions Speed up chat loading and guard selector refresh races 2026-10-10 14:10:35 +02:00
helpers Add context window display controls and price currency selection 2026-10-07 23:31:54 +02:00
tests Speed up chat loading and guard selector refresh races 2026-10-10 14:10:35 +02:00
webui Speed up chat loading and guard selector refresh races 2026-10-10 14:10:35 +02:00
__init__.py Add context window usage indicator 2026-08-23 06:08:41 +02:00
AGENTS.md Speed up chat loading and guard selector refresh races 2026-10-10 14:10:35 +02:00
default_config.yaml Add context window display controls and price currency selection 2026-10-07 23:31:54 +02:00
plugin.yaml Add context window usage indicator 2026-08-23 06:08:41 +02:00
README.md Add context window display controls and price currency selection 2026-10-07 23:31:54 +02:00

Context Window

The bundled Context Window plugin adds a compact usage ring beside the chat's model and agent selectors. Its popover shows token counts and full-window percentages for Messages, System tools, Skills, MCP tools, System prompt, Extras, and Free space.

Older chats gain the detailed breakdown after their next model turn. Mobile and desktop visibility can be changed under Settings > Interface.

Under Plugins > Context Window > Settings, show or hide the whole breakdown block, Price, Cache hit, and Tokens In/Out independently. All four are visible by default. These global settings apply when the popover next refreshes or opens.

Price currency defaults to USD and uses the provider's reported amount directly, with no exchange-rate request. Other currencies convert the visible price using Frankfurter's daily reference rates. Rates are cached for 24 hours; no chat content or prices are sent to the rate service. Hover over a converted amount to see the rate date. If a rate is unavailable, the price is explicitly shown in USD and retries wait five minutes.

When a model provider reports usage, the popover shows price, cache-hit rate, and input/output tokens. Unreported price and cache data are omitted. The context breakdown does not guess model-specific image token costs.

For streamed chat calls, the transport requests LiteLLM's terminal usage event and the plugin drains it after Agent Zero has accepted the response. Price remains hidden when LiteLLM does not report a cost or map the selected model.