Skip to content

Overview

Magic Context gives your coding agent structured session history, deliberate context reduction, and durable cross-session memory. This overview shows how those three systems fit together.

StageWhat happensDeep dive
TaggingTrackable messages and tool outputs receive §N§ identifiers.Context reduction
ReductionThe agent queues spent content with ctx_reduce; eligible old tool output can also be reclaimed on passes already rebuilding the cache.Context reduction
Session historyA separate historian model turns settled conversation into compartments that stay in the prompt and decay to shorter tiers over time.Historian
Durable knowledgeDurable facts become project memory that persists across sessions.Memory
RecallMemory and compartment history inject automatically; ctx_search and ctx_expand retrieve deeper detail.Memory
Off-hours maintenanceA dreamer model consolidates and verifies stored knowledge on configured schedules.Dreamer

The historian and context reduction both keep the active prompt manageable, but they act on different material and leave different results:

LayerWhat it takes inWhat remains in the prompt
HistorianSettled user and agent conversationCompartment summaries that remain in the prompt
ReductionSpent tagged messages and tool outputsCompact dropped or truncated placeholders

The execute threshold tells Magic Context when to batch due work. It is not a target percentage. See Where a pass lands before tuning it.

The raw transcript remains in the local database even when the active prompt contains compartments or dropped placeholders. Project memory persists across sessions and harnesses. The active prompt is therefore a budgeted view of stored knowledge, not the only copy.

Magic Context also preserves provider prompt caching by keeping the early prompt byte-identical between rebuilds. Read Cache architecture for the internal layout and cache terminology.

Magic Context has three effective modes:

  • Primary sessions use historian compartments, reduction, memory, and the full prompt surface.
  • Subagents receive a lighter context-management pass suited to shorter tasks.
  • Compaction-off mode keeps the knowledge layer while your harness, or no compactor, owns the context window.