ValyroUI Русская версия

Context Budget Meter

Context window by part: system prompt, documents, history, overflow and what to trim. Pro · AI chat and agents › Tokens and context

How an LLM's context window is spent: system prompt, memory, documents, history and tool output as one bar against the limit, with the reserve kept for the answer, the overflow past the limit and the fewest cuts that would make it fit.

Installation

npx valyro-cli@latest login
npx valyro-cli@latest add context-budget-meter
npm install valyro-ui-pro

import 'valyro-ui-pro/styles.css';
import { ContextBudgetMeter } from 'valyro-ui-pro';

Props

PropTypeDefault
segments *ContextSegment[]Parts of the prompt in the order they are sent: system, memory, documents, history, tool output.
limit *numberThe model's context window in tokens.
reservenumber0Tokens kept free for the answer. Default 0.
warnAtnumber0.85Share of the window that turns the meter amber. Default 0.85.
onTrim(segmentId: string, tokens: number) => voidAdds Trim buttons to the suggested cuts; called with the segment and how many tokens to cut.
variant'full' | 'compact''full'full (default) adds the legend, breakdown and trim plan; compact is the bar and one line.
loadingbooleanfalseTokens are being counted: skeleton.
errorReactNodeCounting failed: shown instead of the meter.
titleReactNodeHeading. Default: labels.title.
headingLevel2 | 3 | 4 | 53Level of the heading (default 3).
localestringBCP 47 locale for numbers; defaults to the ThemeProvider's.
labelsPartial<Omit<ContextBudgetMeterLabels, 'statuses' | 'kinds'>> & { statuses?: Partial<Record<BudgetStatus, string>>; kinds?: Partial<Record<ContextSegmentKind, string>>; }Overrides for the built-in English text; keys left out keep their defaults.

Related components

Previous: Token Usage · Next: Prompt Editor · All AI chat and agents