Context Window Indicator plugin thumbnail

Context Window Indicator

Shows real-time context window usage percentage with color-coded badge in the chat UI bar. Tracks tokens via tiktoken and updates after each agent response cycle.

Author nibaldox 8 stars Version 1.0.0 Updated

README

Context Window Indicator Plugin

Shows real-time context window usage percentage in the Agent Zero chat UI bar.

Features

  • Displays current token usage as a percentage of the model's context window
  • Color-coded indicator: green (ok), yellow (warning), orange (danger), red (critical)
  • Visual progress bar alongside the percentage
  • Tooltip with detailed token count, context length, model name, and percentage
  • Auto-polls every 5 seconds to keep stats current
  • Responsive design: hides progress bar on mobile, keeps percentage visible

Configuration

Edit default_config.yaml to customize thresholds:

Setting Default Description
warning_threshold 50 Percentage to show yellow warning
danger_threshold 75 Percentage to show orange danger
critical_threshold 90 Percentage to show red critical
show_bar true Show/hide the progress bar
poll_interval_seconds 5 How often to refresh stats

How It Works

  1. Extension Hook: response_stream_end hook computes token stats after each agent response and caches them
  2. API Endpoint: /plugins/context_indicator/context_stats serves cached or fresh stats per context
  3. Alpine Store: Frontend store polls the API and provides reactive data
  4. UI Badge: Rendered in chat-input-bottom-actions-end slot with color-coded display