cortexkit/magic-context

Unbounded context. Memory that manages itself. One session, for life. The hippocampus for coding agents, part of CortexKit.

Magic Context – A Hippocampus for Coding Agents

What it is – Magic Context is a plugin that lives inside the CortexKit ecosystem. It gives large‑language‑model coding agents a long‑term memory that manages itself, so a single session can run for weeks or months without the usual “compaction pauses” that force the agent to forget part of the conversation.

How it works

  • Capture – While the agent works, a background historian reads the full chat log, extracts durable knowledge (design decisions, constraints, naming conventions, etc.) and stores it in a project memory database.
  • Consolidate – An optional dreamer runs during idle time (overnight) to verify those memories against the current codebase, merge duplicates, update docs and promote useful observations into a user‑profile.
  • Recall – On every turn the agent automatically receives the most relevant memories and a compacted view of the conversation. It can also call tools such as ctx_search, ctx_expand, ctx_memory and ctx_note to retrieve or edit information on demand.

Key features

  • Self‑managing context – No external compaction plugins; Magic Context disables any competing context‑management hooks and performs cache‑stable reductions.
  • Tiered historian compartments – Older messages are summarised into weighted summaries, keeping the live prompt window small while preserving the thread.
  • Cross‑harness support – Works with OpenCode, Pi and Oh‑My‑Pi (OMP); memories are shared across these environments.
  • Configurable models – You pick a cheap model for the historian and an optional model for the dreamer; embeddings default to a local MiniLM model.
  • CLI wizard – npx @cortexkit/magic-context@latest setup detects your environment, installs the right plugin (@cortexkit/opencode-magic-context, @cortexkit/pi-magic-context, etc.) and disables conflicting compaction settings.
  • Diagnostics – npx @cortexkit/magic-context@latest doctor checks for conflicts, validates the database and can auto‑fix common issues.

Typical workflow

  1. Run the setup wizard (or add the plugin manually to opencode.jsonc).
  2. Provide a model ID for the historian (e.g., provider/model-id).
  3. Start coding; the historian silently builds a memory store.
  4. Optionally enable the dreamer to run nightly maintenance.
  5. Use /ctx‑search, /ctx‑note, etc., to query or edit memories during a session.

Why it matters – Without Magic Context each coding‑agent session starts with a blank slate and periodically pauses to compress its context, losing continuity. Magic Context turns a disposable agent into a long‑term teammate that remembers decisions, code conventions and past discussions, reducing repetitive prompting and improving productivity.


Quick‑start summary

# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/cortexkit/magic-context/master/scripts/install.sh | bash
# Windows PowerShell
irm https://raw.githubusercontent.com/cortexkit/magic-context/master/scripts/install.ps1 | iex
# Or any OS via npx
npx @cortexkit/magic-context@latest setup

Add the plugin to your harness config, create magic-context.jsonc with the historian model, and you’re ready to go.


Part of CortexKit – Magic Context is the “hippocampus” piece; together with the AFT (sensorimotor cortex) and the upcoming Alfonso (prefrontal cortex) it forms a full‑brain suite for autonomous coding agents.

Related

  • Project
  • Project
  • Project
  • Project
  • Project