Context Management

How Context Pilot manages what the AI sees — the core concept that makes everything else work.

Overview

Every message sent to the LLM includes a set of context elements — the system prompt, tool definitions, file contents, memories, logs, conversation history, and more. Context Pilot makes these elements visible, measurable, and manageable.

ℹ️ Key insight In most AI tools, context is invisible — you can't see what the AI knows. In Context Pilot, every context element is a visible panel with a measured token count.

Context Elements

Context elements are ordered by priority. The LLM sees them in this order:

TypeDescriptionExample
System promptActive agent's instructions~100 tokens
Tool definitionsAll enabled tool schemas~10K tokens
Core panelsMemories, callbacks, library, scratchpad~3K tokens
File panelsOpened source filesVariable
Dynamic panelsGit, search results, console outputVariable
History panelsPrevious conversation segmentsVariable
TreeDirectory structure with descriptions~2K tokens
TodosActive task listVariable
LogsTimestamped event logVariable
ConversationCurrent chat messagesGrowing

Panels

Panels are the visual representation of context elements in the sidebar. Each panel has:

Core panels (P1-P7)

These cannot be closed and are always present:

Dynamic panels (P8+)

Created by tool calls — file opens, git commands, search results, console output. The AI can close these with Close_panel to free context space.

Token Budget

Context Pilot tracks token usage across all elements. The Statistics panel (P3) shows current usage vs. the budget:

⚠️ Context overflow When context approaches the budget, the AI should close stale panels, summarize histories, and remove unnecessary elements. If it doesn't, you can ask it to clean up.

Context Management Strategies

The AI manages its own context

Context Pilot's AI is instructed to manage context proactively:

You can help

Element Lifecycle

  1. Created — a tool call opens a file, runs a command, creates a panel
  2. Active — the element is visible to the AI and counted in the token budget
  3. Auto-refreshed — some panels (git, github) refresh periodically
  4. Closed — removed from context via Close_panel or auto-suicide

Auto-suicide

Some panels clean themselves up automatically: