agent-zero/plugins/_context_window/README.md
Alessandro 935fb5cdcc Add context window display controls and price currency selection
Add plugin settings to toggle the full context breakdown and each provider
usage row. Match price typography to the cache and token summary rows.

Keep USD amounts unchanged without exchange-rate requests. Convert non-USD
prices using validated Frankfurter rates cached for 24 hours, with dated
tooltips and an explicit USD fallback when a rate is unavailable. Preserve
stored provider usage and back off failed lookups for five minutes.

Validation: 20 context-window plugin tests pass. Verified settings persistence,
EUR price rendering, USD fallback, and exchange-rate lookup against the live
Docker runtime at localhost:32081.
2026-10-07 23:31:54 +02:00

1.5 KiB

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.