Loading component…
Loading component…
What fills an agent's context window, as a living treemap – system prompt, tools, memory, files and chat as tiles that glide as it grows, and compaction squeezing old turns
To reuse this local React demo, copy all files from the Code tab into the same folder, then import ContextMap from ./context-map.
import { ContextMap, type ContextBlock } from "@/components/ui/context-map";
const blocks: ContextBlock[] = [
{ id: "system", label: "System prompt", kind: "system", tokens: 6200 },
{ id: "tools", label: "Tool definitions", kind: "tools", tokens: 14800 },
{ id: "spec", label: "checkout.spec.ts", kind: "file", tokens: 8200, detail: "Read at 0:09" },
{ id: "chat", label: "Chat", kind: "chat", tokens: 41000 },
{ id: "run", label: "Test run · 20×", kind: "result", tokens: 22400 },
];
export function Context() {
return <ContextMap blocks={blocks} limit={200000} model="Opus 5.5" modelIcon={<ClaudeLogo />} />;
}| Name | Type | Default | Description |
|---|---|---|---|
| blocks | ContextBlock[] | { id, label, kind, tokens, detail?, icon?, items? } – every part of the context, in the order the tiles should sit; items (label + icon) are listed on hover | |
| kind | "system" \| "tools" \| "memory" \| "file" \| "chat" \| "result" \| "summary" | Per block – picks its tint | |
| limit | number | The context window's size in tokens – what's left shows as dashed free space | |
| model / modelIcon | string / ReactNode | The model and its maker's logo, next to the title – the window's size follows as a small tag | |
| agents / agent / onAgentChange | ContextAgent[] / string / (id) => void | Agents to switch between – the tray shows the current one as a menu, its limit replaces limit | |
| view / onViewChange | "before" \| "after" / (view) => void | Controlled: which side of the compaction shows – leave it out and the switch keeps its own | |
| status | string | A short status on the tray – e.g. "Compacting" | |
| onSelect | (block \| null) => void | A tile was clicked – null for the free space | |
| title | string | "Context" | Heading on the tray |
| className | string | Extra class on the root |
The area keeps its height; tiles too small for a label show only their color – point at them for the details
Under 480px the area is shorter and the numbers move to a line of their own
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"