Your coding agent shouldn't have amnesia
Magic Context gives coding agents persistent, self-managing memory so they stop starting every task as a blank slate.

What it does
Magic Context is a context-management and memory layer for coding agents like OpenCode and Pi. It runs a background historian that continuously compresses conversation history into tiered, scored compartments and lifts durable project knowledge into structured memory. The result is a single long-running session that never pauses for compaction and never forgets the decisions made three weeks ago.
The interesting bit
The project commits fully to the neuroscience metaphor: an overnight “dreamer” agent consolidates memories, merges duplicates, verifies them against the live codebase, and maintains architecture docs while you sleep. Because all of this happens in the background, you can run the historian and dreamer on cheap or local models while your primary agent keeps the expensive coding muscle.
Key highlights
- Continuous background compression: old history is summarized into tiered compartments on the fly, so the live context window stays small without compaction pauses.
- Cache-aware operations: reductions and updates are queued to avoid thrashing the prompt cache, keeping prefix cache hits stable across the session.
- Automatic knowledge capture: decisions, constraints, and conventions are extracted from history and categorized into project memory without manual tagging.
- Cross-harness memory pool: memories and embeddings are shared between OpenCode and Pi sessions via a single CortexKit store.
- Fail-safe compatibility: the plugin disables itself automatically if it detects conflicting context managers like DCP or oh-my-opencode.
Caveats
- Pi support is explicitly marked beta and requires Pi version
>= 0.74.0. - The plugin is tightly coupled to the CortexKit ecosystem; if you do not use OpenCode or Pi, there is nothing here for you.
- It intentionally takes over context management end-to-end and will refuse to run alongside other context plugins.
Verdict
Worth a look if you run long-lived coding agents and are tired of context windows collapsing mid-task. Skip it if you are not using OpenCode or Pi, or if you prefer to manage context manually.
Frequently asked
- What is cortexkit/magic-context?
- Magic Context gives coding agents persistent, self-managing memory so they stop starting every task as a blank slate.
- Is magic-context open source?
- Yes — cortexkit/magic-context is open source, released under the MIT license.
- What language is magic-context written in?
- cortexkit/magic-context is primarily written in TypeScript.
- How popular is magic-context?
- cortexkit/magic-context has 1.4k stars on GitHub and is currently accelerating.
- Where can I find magic-context?
- cortexkit/magic-context is on GitHub at https://github.com/cortexkit/magic-context.