CortexcnCortexcn
Pro

Context Window

An LLM's context window as a ruled tape, with the system prompt, tools, memory, documents, chat, and a streaming reply each in its own texture, where the chat folds into a short summary once the window crosses its compaction line.

Context window

Sage 2

76,900/ 128,00060% full

System prompt
2,400
Tools
3,100
Memory
6,800
Documents
18,400
Chat
46,200
Reply
0

Turn 7

Installation

ProPart of Cortexcn Pro

The source for context-window comes with a Cortexcn Pro license, along with every other chart and the website templates. Pick a license on the pricing page.

Already have a license? Open the code

Usage

import { ContextWindow } from "@/components/context-window";
<ContextWindow
  model="Sage 2"
  capacity={128000}
  threshold={0.85}
  start={{ system: 2400, tools: 3100, memory: 6800, documents: 18400, chat: 46200 }}
/>

The tape is the whole window, ruled in thousands of tokens. Each part takes its share of the width and has its own texture, so the parts read apart in light and dark mode and without color. Use it on the page for an AI product to explain memory, retrieval, and long conversations, or in an agent's settings to show what fills the window.

Examples

A smaller window

A 32k window for a coding assistant, with two parts renamed and the line at 80%.

Context window

Brisk 3

23,800/ 32,00074% full

System prompt
1,200
Tools
2,400
Project notes
1,800
Code files
9,600
Chat
8,800
Reply
0

Turn 7

Static

With animated={false}, the window shows its starting parts and nothing moves.

Context window

Sage 2

76,900/ 128,00060% full

System prompt
2,400
Tools
3,100
Memory
6,800
Documents
18,400
Chat
46,200
Reply
0

Turn 7

Behavior

  • While the window is on screen, a reply streams in with moving stripes. When it finishes, it joins the chat and some turns fetch more documents, and the turn count goes up.
  • When the window crosses the dashed line at threshold, the tape is outlined, the chat folds into a short summary, and only the newest documents stay. Then the next reply streams in.
  • The sizes of the replies, the documents, and the summary scale with capacity.
  • The line under the legend says what just happened, and screen readers hear it as it changes.
  • With reduced motion enabled, the window shows its starting parts and nothing moves.
  • The tape and the ruler are hidden from screen readers; the legend lists every part with its tokens.

Props

PropTypeDefaultDescription
capacitynumber128000How many tokens the window holds
thresholdnumber0.85Share of the window at which the chat is compacted
modelstring"Sage 2"The model's name, beside the title
titlestring"Context window"The title over the tape
startPartial<Record<ContextWindowPart, number>>Sample sizesTokens in each part when the window first shows
labelsPartial<Record<ContextWindowPart, string>>The part namesThe name of each part in the legend
accentstring"var(--foreground)"Color of the streaming reply
animatedbooleantrueStream, fetch, and compact while on screen
classNamestring-Extra classes on the frame

ContextWindowPart is "system" | "tools" | "memory" | "summary" | "documents" | "chat" | "reply".