Skip to content

Context Management

Context is all the information Kodik knows during a conversation. Understanding how it is built helps you get more accurate and consistent results.

Every language model has a context window — the maximum number of tokens (roughly 3/4 of a word each) it can hold at once. This includes the system prompt, conversation history, contents of mentioned files, open-tab information, and tool call results.

As the context fills up, response quality degrades well before the formal limit is reached — in practice this is noticeable around 200–300K tokens even on models with larger windows.

On each request Kodik assembles the environment from several sources:

Active editor tabs (<active_tabs>) — files open in visible editor panels right now. Media and binary files are excluded automatically.

Opened tabs (<opened_tabs>) — files open in the editor but not currently in focus. Overlap with active tabs is deduplicated.

Mentions (<user_mentions>) — files, folders, and line ranges explicitly referenced via @ Mentions. Files blocked by .kodikignore are excluded.

Terminal context (<terminal_context>) — terminal output attached via @terminal:<name>.

Rules and instructions — contents of .kodik/rules, global rules, and AGENTS.md are injected into the system prompt.

Memory — entries from .kodik/memories are included in the system prompt.

You can exclude open files from context via the Context tab in the Kodik panel.

Kodik automatically compacts the conversation history when approaching the context limit. See Auto-compact for full details.

In short: when tokens exceed 70% of the context window (or a lower 30% threshold when cache has expired), Kodik creates a summary of the conversation and replaces old messages with it. The most recent user message is always preserved. If the context overflows during an active request, Kodik prompts you to compact manually.

Manual compaction is also available via /compact.

What to include explicitly:

  • Files directly relevant to the task — via @Mentions
  • Line ranges to pinpoint the exact area of interest
  • Terminal output with the error or build result

What to exclude:

  • Open but irrelevant tabs — via the Context panel
  • Files that should not reach the agent — via .kodikignore

Rules and instructions (.kodik/rules) occupy permanent space in the system prompt, so keep them concise and current.

Context from a current conversation is not automatically carried into a new session. For continuity, use:

  • Rules — persistent project instructions
  • Memory — accumulated facts about the project
  • AGENTS.md — architecture and conventions
  • Codebase indexing — semantic search over code without manually pointing to files
  • Start a fresh session when switching to unrelated tasks — this clears context and reduces the chance of confusion.
  • Use MCP servers to pull context from external knowledge bases.
  • Screenshots can be passed as context for models that support image input.