The idea: keep a working set, retain the original

A model can only receive a bounded amount of text at once. Compaction shortens older conversation content. History VM keeps exact eligible history on disk and puts small references in the prompt. Context virtualization adds structured views and summaries over that history.

Start with an ordinary interactive session and inspect /context. For a longer session:

mini-a conversation=./research.json historyvm=true

The conversation path must be writable. As eligible older tool output accumulates, Mini-a stores it in a companion history directory and makes retrieval tools available. Short conversations may show little difference. /context vm reports the projection state; it is not a guarantee of billed savings.

If you only need to shorten a current conversation, /compact may be enough. If exact old output matters, use History VM and retain its sidecar alongside the conversation. Context virtualization requires History VM. See session options.

Automatic Performance Optimizations

mini-a includes several built-in optimizations that reduce token consumption and keep conversations within context limits without manual intervention.

  • Conversation compaction — When the conversation grows too long, mini-a automatically compresses earlier turns while preserving essential context. Trigger manually with /compact.
  • Context summarization — Long tool outputs and intermediate results are summarized to save tokens. Trigger manually with /summarize.
  • Token usage optimization — The framework tracks token counts and adjusts behavior to stay within budget.
  • Smart prompt caching — Repeated prompt patterns are cached where the provider supports it, reducing redundant API calls.

Key Parameters

Parameter Description Default
maxcontext Approximate context budget (tokens). Deduplicates at 60% and summarizes at 80% of the budget; 0 leaves proactive compaction off (provider overflow recovery still applies) 0
contextguard Guardrails for large tool output when maxcontext is unset false
# Example: constrain the context budget
mini-a maxcontext=32000

For tool-heavy conversations where older output must stay exactly recoverable, History VM (historyvm=true) keeps the full history on disk and sends the model only a bounded working set, with history_search, history_get, and history_expand to page exact text back in.


Performance Tuning

Optimizing mini-a for speed, cost, and reliability across long-running or high-volume sessions.

Context Management

The maxcontext parameter sets an approximate context budget (in tokens). It defaults to 0, which leaves proactive compaction off: Mini-A then relies on provider overflow recovery, or on contextguard=true, so set it explicitly for long-running sessions. When the conversation approaches the limit, mini-a compacts the context by removing duplicate observations (at 60% of the budget) and then summarizing older turns (at 80%):

mini-a maxcontext=40000

Auto-compaction preserves the most recent and most relevant context while discarding redundant information. Summarization runs as isolated, tool-free requests between execution steps, and when a provider reports a context overflow, Mini-A replaces the main and low-cost provider histories with the compact context while keeping system/developer instructions. For tool-heavy conversations that need exact recall of older output, see History VM and Context Virtualization.

Token Optimization

Prompt profiles trim optional guidance, while context compaction summarizes or removes eligible older content. Summaries can omit detail; retain source files or use History VM when exact recovery matters. Tool caching is a separate, configurable mechanism.

Manual Context Control

In interactive console mode, two commands give you direct control over context size:

  • /compact [n] — Immediately reduces the conversation context by summarizing and removing older turns while keeping up to the latest n exchanges (default 6). Use this when you notice the model slowing down or losing track of earlier instructions.
  • /summarize [n] — Creates a structured summary of the entire conversation so far, replaces older history with that summary, and keeps up to the latest n exchanges (default 6). This is more aggressive than /compact and is useful for very long sessions.

Response Length

Ask for a shorter answer in goal or rules. A hard per-response token limit is provider-specific model configuration, not a public Mini-a maxtokens flag. For the total automatic-orchestration budget, use runmaxtokens with orchestration=auto; this limits admission of work rather than the length of one answer.


History VM and Context Virtualization

For long, tool-heavy conversations, Mini-A can keep the exact history on disk and send the model a bounded working set. Both phases are opt-in and require a writable conversation= path.

mini-a conversation=chat-history.json historyvm=true goal="continue the investigation"

Phase 1: historyvm

Mini-A writes append-only canonical events and checkpoints under chat-history.json.historyvm/. Older, eligible, large assistant/tool messages are represented by small HISTORY_VM_REFERENCE entries. While enabled, the model receives history_search, history_get, and history_expand, so it can recover exact archived text in bounded pages. The conservative safe policy (historyvmmode, the only supported mode) keeps user messages, system/developer instructions, recent exchanges, in-flight tool protocol data, and unknown multimodal shapes inline.

  • Try it first: historyvmshadow=true captures events and estimates savings without changing provider requests or adding retrieval tool schemas. If both flags are set, enabled mode wins.
  • Diagnostics: /context vm in the interactive console shows object state and token deltas.
  • Lifecycle: /clear and explicit web conversation deletion remove the owned sidecar. Automatic web expiry preserves history when historykeep=true and deletes the sidecar otherwise. /rewind records a new branch; default retrieval excludes the abandoned branch without deleting its events.
  • The VM is independent of usememory, and it creates retained conversation data even when history listing is disabled.

Phase 2: contextvirtualization

Enable it with historyvm=true contextvirtualization=true. It extends the same journal with stable typed handles, deterministic L0–L4 representations, hierarchical summaries, coarse-to-fine retrieval, bounded line/section/JSON-path reads, utility-per-token assembly, typed provenance and supersession graphs, and consumer-specific views for executor, planner, advisor, validator, and delegates. At each model call the projection preserves system/developer instructions, real user constraints, recent exchanges, and unknown content; completed native tool-call groups are preserved or frozen together. Exact content is restored before the conversation is persisted and stays retrievable with context_search, context_get, context_expand, context_children, and context_related. For L4 reads, pass nextCursor back as the next offset.

Use contextvirtualizationshadow=true to dry-run the same projection while still sending the Phase 1 context. Shadow numbers are projections, not provider-billed savings, and stable-prefix serialization does not imply provider prompt caching.

Flags Behavior
historyvm=false historyvmshadow=false Legacy Mini-A
historyvm=true contextvirtualization=false Phase 1
historyvm=true contextvirtualization=true Phase 2

Neither phase is enabled silently. Configured budgets account for the serialized conversation, current prompt, tool schema estimates, a safety allowance, and an output reserve. Protected overflow stops the invocation rather than silently deleting constraints, and counts are application estimates. With maxcontext=0, virtualization can still shrink eligible old messages, but Mini-A does not claim a verified hard context bound. Delegates receive task-specific knowledge rather than the parent’s full knowledge field, and children do not inherit the parent’s History VM by default. Semantic compression is available only through the MiniAHistoryVM module API; the CLI and web UI use deterministic representations.

Context-budget recovery

Native tool rounds check the effective budget between recursive provider calls, for streaming and non-streaming adapters. The latest synthetic goal stays exact; older eligible scaffolding may be paged, while real user instructions remain protected. Ollama exchanges retain tool-name metadata and completed Markdown/JSON examples are not redispatched as actions. Terminal errors separate protected conversation, current prompt, tool schemas, instructions, safety allowance, output reserve and selected context. Narrow oversized input/schemas or explicitly raise maxcontext; auxiliary models do not recursively recover. Canonical append/checkpoint writes are serialized and use unique atomic-write temporaries to avoid concurrent checkpoint collisions.

With active Phase 2 and positive maxcontext, an oversized request gets one emergency projection. Recent completed assistant work and complete tool exchanges may use bounded representations with recovery handles; exact originals remain in the canonical journal. Real user messages, instructions, incomplete tool exchanges and unknown/multimodal content stay exact. The provider view changes only if the complete request fits.

If executor working notes still exceed the budget, isolated chunked summarization rebuilds the prompt while preserving the goal, explicit constraints, hooks and new inbox messages. There is at most one note-recovery attempt per logical request and three per run. Failed, empty or nonshrinking summaries preserve the originals. Recovery does not reset provider history, raise the budget or lower the output reserve.

Terminal errors report separate estimates for protected conversation, prompt, tool schemas, separately charged instructions, safety allowance, output reserve and selected context, plus the recovery outcome. Narrow inputs/schemas or explicitly raise maxcontext when protected input cannot fit or canonical backing is unavailable. Auxiliary models do not recursively recover; Phase 1, shadow, legacy and maxcontext=0 keep their existing behavior.

Current runtime status takes precedence over historical/child diagnostics. Delegation metrics labeled diagnostics_scope.scope=child_execution and retrieved child_diagnostics describe that child, not the parent’s History VM settings.

Web history in S3

./mini-a-web.sh usehistory=true historyvm=true historys3bucket=my-bucket historys3prefix=sessions/

Each prompt checkpoint and final-answer checkpoint uploads the conversation and a versioned canonical VM snapshot in the existing S3 JSON object. A session opened on a new host, or after local cache loss, restores the journal and rebuilds derived indexes before the VM starts, and older objects without a snapshot fall back to legacy import. Failed uploads keep the local checkpoint and retry at the next one; newer valid local state wins over an older matching S3 snapshot. Explicit history deletion removes the remote object and local sidecar even with historykeep=true. This supports one active writer per conversation and sequential movement between hosts, not concurrent distributed writers, and full snapshots increase storage and transfer size. If the local journal cannot be written, Mini-A keeps content inline and reports degraded persistence; a degraded VM is never uploaded as a valid snapshot.