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.
Context Elements
Context elements are ordered by priority. The LLM sees them in this order:
| Type | Description | Example |
|---|---|---|
| System prompt | Active agent's instructions | ~100 tokens |
| Tool definitions | All enabled tool schemas | ~10K tokens |
| Core panels | Memories, callbacks, library, scratchpad | ~3K tokens |
| File panels | Opened source files | Variable |
| Dynamic panels | Git, search results, console output | Variable |
| History panels | Previous conversation segments | Variable |
| Tree | Directory structure with descriptions | ~2K tokens |
| Todos | Active task list | Variable |
| Logs | Timestamped event log | Variable |
| Conversation | Current chat messages | Growing |
Panels
Panels are the visual representation of context elements in the sidebar. Each panel has:
- ID — e.g., P5, P11, P23
- Type — file, console, git, search, etc.
- Token count — how much context space it uses
- Content — visible in the main panel area
Core panels (P1-P7)
These cannot be closed and are always present:
- P1 — Todo list
- P2 — Library (agents, skills, commands)
- P3 — Statistics (context usage, git changes)
- P4 — Tools (all 58 tools with status)
- P5 — Directory tree
- P6 — Memories
- P7 — Spine (notifications, auto-continuation)
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:
- Budget — maximum tokens the model supports (~200K for Claude Sonnet)
- Threshold — soft limit where context should be managed (~140K)
- Current usage — sum of all context element tokens
Context Management Strategies
The AI manages its own context
Context Pilot's AI is instructed to manage context proactively:
- Close files after editing (they served their purpose)
- Close old conversation histories (preserving info as logs/memories first)
- Close search result panels after extracting relevant information
- Close console panels after checking output
You can help
- Ask the AI to "clean your context" when things feel cluttered
- Use the sidebar to see which panels are consuming the most tokens
- The Statistics panel (P3) shows accumulated costs per element
Element Lifecycle
- Created — a tool call opens a file, runs a command, creates a panel
- Active — the element is visible to the AI and counted in the token budget
- Auto-refreshed — some panels (git, github) refresh periodically
- Closed — removed from context via
Close_panelor auto-suicide
Auto-suicide
Some panels clean themselves up automatically:
- File panels — suicide when the file is deleted from disk
- Console panels — suicide when the session is lost or a newer callback panel replaces it
- Watchers — suicide when their target console session vanishes