Skip to content

Context management

EventideMiles edited this page Oct 6, 2026 · 2 revisions

Context management

Eventide Quill is built for local models, and local models have finite context windows. Rather than letting a long conversation, review, or subagent run silently grow past what the server accepts, Quill estimates every request before it is sent and compacts history when it crosses a threshold you control.

This page explains how that works — and how to configure the server side (llama.cpp, LM Studio, and similar OpenAI-compatible endpoints) so Quill's numbers match reality.

How Quill tracks context

Quill does not tokenize your text. It estimates:

  • Roughly one token per four characters of message content.
  • A fixed 512 tokens per image — a deliberate slight overestimate, so image-heavy chats trigger compaction a little early rather than too late.

Every request — chat history, injected vault context, the pending message — is measured against the Context window set on the provider's card in Settings → AI providers (32768 by default for a new provider; a power-of-two dropdown with a custom option).

When an estimate crosses the Compaction threshold — a percentage of that window — Quill starts compacting. Find it under Settings → Model behaviors → Context engine. The default is 80; the allowed range is 50–95.

Automatic compaction

Compaction runs in two layers, cheapest first:

  1. Deterministic refinement. Before any model call, Quill surgically compresses bulky or now-stale tool content already in the conversation:

    • Drafts you have accepted or discarded become short outcome markers, so the model keeps the fact without re-reading the verbatim text.
    • Stale vault reads are replaced with a "re-run the lookup" marker once the underlying note has been edited.
    • When space is tight, the oldest bulky reads are trimmed first — the model can always re-fetch current state.

    No model call is spent on any of this. If refinement alone brings the request back under the threshold, the AI step is skipped entirely. Controlled by the "Refine accepted edits out of context" toggle (default on).

  2. AI summarization. If the conversation is still over, older turns are summarized into a short context message. The system prompt and your most recent turns stay verbatim, so the model keeps the immediate thread of what you were doing. The summary's length is set by "Compact summary length" (1–20 sentences, default 3).

These checks run at every growth point: before each send and again mid-tool-loop in each co-writer chat mode (discuss, coach, lorebook), plus editorial feedback, critical analysis, manuscript analysis, and subagent runs.

When summarization fails

Note

Introduced in Quill 2.3.0.

A compaction summary is itself a model call, and it can fail — the server restarts, runs out of memory, or drops the connection. When that happens (for any reason other than you cancelling), or when the model returns an empty summary, Quill now falls back to a deterministic compaction instead of giving up:

  • The oldest conversation turns are dropped outright, always as whole tool rounds — an assistant tool call is never separated from its results, so the request stays well-formed.
  • The system prompt and injected context heads (memory index, tool guidance) are kept verbatim.
  • A short marker message notes the drop: it tells the model that older turns were removed to fit the context window and that it should ask you to restate anything that seems missing.
  • Your most recent turns are kept verbatim.

The practical effect: a failed summary can never leave an oversized request headed for the server — the kind of request a llama.cpp server answers with a rejection or an out-of-memory crash.

Two guardrails:

  • Cancelling still cancels. The fallback never swallows your abort; a cancelled generation stays cancelled.
  • Very short conversations are left untouched. With fewer than four turn-groups there is nothing meaningful to free, so Quill keeps the conversation as-is.

Long manuscripts

Two pipelines handle manuscripts too big for a single request:

  • Chunked feedback. When a manuscript exceeds the model's window, editorial feedback splits the text into paragraph-aware chunks, reviews each chunk in its own pass, then a synthesis call merges the per-section notes into one cohesive report. Every part of the manuscript is read in its original prose — never a summary of a summary. Only the final synthesis streams to the panel.
  • Manuscript analysis compaction. Whole-manuscript analysis prepares its payload with one of three strategies: send the full text when it fits; otherwise pick the most relevant chunks via embeddings (when an embed model is configured); otherwise compress the text chunk-by-chunk with the AI. Queued manuscript jobs snapshot their chapters at submit time, so you can keep writing while the job waits its turn.

Keeping requests lean

  • Tool results are truncated per tool. Every vault and research tool declares a token cap. An oversized result is cut off with a [result truncated at N tokens] marker rather than flooding the conversation.
  • Subagents run in fresh contexts. A lorebook batch or research subagent starts with only its own system prompt and task brief — never your chat history — so a long batch cannot inflate the main conversation. The subagent's own loop is subject to the same compaction and fallback as everything else.

Local servers (llama.cpp / LM Studio, etc.)

This is the critical part for llama.cpp-style servers: Quill compacts against the context window configured on its provider card — not the one your server actually enforces. If the two disagree, the server wins: it rejects oversized requests (or crashes) before Quill's compaction ever gets a chance to help.

  • Match the numbers. If your server runs with -c 8192, set the provider's Context window to 8192 or lower. The same applies to LM Studio's per-model context length setting. A configured window larger than the server's real context is the main cause of hard failures and out-of-memory errors on local setups.
  • Model picker hint. When you fetch the model list from an OpenAI-compatible endpoint, Quill shows the server-reported context on each suggestion row (for example, "131,072 context tokens") — when the server reports it. LM Studio exposes its context length, so the hint appears there. llama.cpp's own server doesn't expose it in the field Quill reads, so its rows simply show no hint rather than a guessed number — check the server's startup log for the context it actually loaded.
  • Selection-time warning. If you pick a model whose reported context is smaller than the provider card's Context window, Quill immediately shows a warning naming both numbers, so you can fix either side while it's fresh: lower the Context window on the provider card, or raise the server's context. No warning appears when the configured window is equal or smaller — compacting a little earlier than strictly necessary is safe.
  • Cloud providers get this for free. Anthropic models report their input-token limit and Gemini models report theirs, so the hint and mismatch warning work there without extra configuration.

Why did the model "forget" something?

After compaction — AI-summarized or deterministic — older details exist only in compressed form. The marker message left by the fallback explicitly invites the model to ask you to restate anything that seems missing. If a long session drifts, the cheapest fix is usually: start a new chat (previous sessions are saved to History), or paste the relevant lore entry back into the conversation.

Problems?

  • For installation and setup, see the README.
  • If requests still fail after checking the numbers above, open an issue and include your provider's Context window value and your server's context setting (-c on llama.cpp, the context length in LM Studio).

Clone this wiki locally