Skip to main content

Context Usage

Every turn, an agent carries a context window: the system prompt, the conversation so far, tool definitions, and any skills or dynamic sections it pulled in. That window is finite, and once it fills, quality and cost both suffer. This page is about seeing what's in it and keeping it lean.

What fills the window

  • Instructions are the agent's system prompt and any prompt templates.
  • History is the prior messages in the thread (unless you scope it).
  • Tools are the definitions of every tool the agent can call.
  • Skills are reference material the agent loads at runtime.
  • Dynamic sections are context you inject per message via getMetadata.

The biggest lever is usually skills: progressive disclosure keeps detailed references out of the window until a task actually needs them.

Watch it in the client

@distri/react ships components that surface context health right in the chat, so users (and you) can see how full the window is:

Component / hookShows
ContextIndicatorA compact gauge of how full the window is.
ContextUsagePanelA breakdown of what's consuming context.
ContextControlControls to trim or manage the window.
useContextHealth()The same data as a hook, for custom UI.
import { ContextIndicator } from '@distri/react';

// Drop it into your chat header
<ContextIndicator />

Keep it lean

  • Split large skills so only the relevant reference loads (progressive disclosure).
  • Gate optional prompt sections with conditional templates so they appear only when relevant.
  • Scope history per thread instead of replaying everything.

See it per run

For a token-level accounting of a single run, including prompt vs. completion tokens per tool call, use Traces.