Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Context Management — KiloCode


title: Context Management — KiloCode authors:


Context Management — KiloCode

Agent version: v7.1.20 (commit cb0c58c0) Analysis date: 2026-04-05

What’s Different: Agent Manager

KiloCode adds an Agent Manager (VS Code extension) for multi-session orchestration:

This doesn’t change the per-session context management algorithm — each session still uses the same filterCompacted → toModelMessages → isOverflow → compaction pipeline as OpenCode. But it adds a multi-session layer that OpenCode doesn’t have: users can work on multiple files/branches simultaneously, each with independent context budgets.

Key File: Agent Manager location

The Agent Manager lives in the VS Code extension portion of the monorepo, separate from the core packages/opencode/ runtime. It manages session lifecycle (create, pause, resume, delete) and coordinates the underlying kilo serve processes.

Shared Architecture with OpenCode

The following are inherited directly from OpenCode (no code changes):

ComponentBehavior
StorageSQLite (MessageTable + PartTable)
History retrievalfilterCompacted — stops at compaction markers
Token countingisOverflow() — context − 20K buffer
CompactionDedicated agent (no tools) with structured summary
PruningPRUNE_MINIMUM = 20_000, PRUNE_PROTECT = 40_000
Tool truncationMAX_LINES = 2000, MAX_BYTES = 50KB
Media handlingStripped during compaction
Overflow detectionProvider error pattern matching

All code paths are in packages/opencode/src/ — the same package as OpenCode.

Key Files

FileRole
packages/opencode/src/session/prompt.tsMain loop — identical to OpenCode
packages/opencode/src/session/message-v2.tsfilterCompacted — identical to OpenCode
packages/opencode/src/session/compaction.tsCompaction agent — identical to OpenCode
VS Code extension (Agent Manager)Multi-session orchestration — KiloCode unique