# Magic Context: Unbounded, Self-Managing Memory for AI Coding Agents

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Source: osrepos.com
Repository profile: https://osrepos.com/repo/cortexkit-magic-context
Generated for open source discovery and AI-assisted research.

Magic Context is a powerful GitHub repository that provides unbounded, self-managing memory for AI coding agents. Acting as the 'hippocampus' for agents, it ensures continuous learning and recall across sessions without disruptive context compaction. This tool, part of CortexKit, allows agents to build lasting project knowledge and maintain context efficiently.

GitHub: https://github.com/cortexkit/magic-context
OSRepos URL: https://osrepos.com/repo/cortexkit-magic-context

## Summary

Magic Context is a powerful GitHub repository that provides unbounded, self-managing memory for AI coding agents. Acting as the 'hippocampus' for agents, it ensures continuous learning and recall across sessions without disruptive context compaction. This tool, part of CortexKit, allows agents to build lasting project knowledge and maintain context efficiently.

## Topics

- AI Agents
- Agent Memory
- Context Management
- TypeScript
- AI Development
- LangChain
- CortexKit
- Open Source

## Repository Information

Last analyzed by OSRepos: Wed Sep 02 2026 20:54:55 GMT+0100 (Western European Summer Time)
Detail views: 3
GitHub clicks: 1

## Safety Notice

OSRepos shares public repositories for knowledge and discovery only. Review source code, dependencies, licenses, and security implications before running or installing anything.

## Content

## Introduction

Magic Context is an innovative solution designed to address the persistent memory challenges faced by AI coding agents. It provides an "unbounded context" and a self-managing memory system, akin to a hippocampus, enabling agents to retain knowledge and context across long-running sessions. This crucial component of the CortexKit ecosystem ensures that agents can learn, remember, and recall project-specific information without the typical limitations of short-term memory or disruptive context management processes.

## Why Use It & Key Benefits

Magic Context transforms how AI agents interact with their environment and tasks, offering several significant advantages:

*   **Uninterrupted Workflow**: Agents never stop to manage their context, eliminating disruptive "compaction" pauses. The system handles context management continuously in the background, ensuring a smooth and uninterrupted workflow.
*   **Persistent Memory**: Agents never forget. Magic Context builds lasting project knowledge, allowing agents to accumulate and recall information across weeks, months, or even years.
*   **Historian for Knowledge Capture**: The historian component automatically compresses old raw history into tiered chambers, summarizing permanent knowledge, such as decisions, constraints, and conventions, into project memory. This process builds your agent's memory from the work it already performs.
*   **Dreamer for Memory Consolidation**: An optional dreamer agent works in the background, similar to how sleep consolidates human memories. It checks memories against the current codebase, organizes redundancies, refines phrasing, and upgrades recurring insights, ensuring memory quality over time.
*   **Intelligent Recall**: Active project memories and compressed session history are automatically injected into the agent's context. Agents can also use `ctx_search` to query project memories, raw conversation history, and indexed Git commits, providing relevant information precisely when needed.
*   **Cache-Aware Design**: The system is designed with a stable cache layout, ensuring that background operations never invalidate the cached prompt prefix. This maintains efficiency and reduces costs with cache-aware providers.
*   **Cross-Session and Cross-Harness Persistence**: Memories persist seamlessly across different sessions and are shared between various harnesses like OpenCode and Pi, allowing for a unified knowledge base.

## Installation

Getting started with Magic Context is straightforward. You can use the interactive setup wizard which detects your models, configures everything, and handles compatibility.

**macOS / Linux:**
bash
curl -fsSL https://raw.githubusercontent.com/cortexkit/magic-context/master/scripts/install.sh | bash


**Windows (PowerShell):**
powershell
irm https://raw.githubusercontent.com/cortexkit/magic-context/master/scripts/install.ps1 | iex


**Or run directly (any OS):**
bash
npx @cortexkit/magic-context@latest setup


The wizard automatically detects your harnesses, adds the necessary plugin, disables built-in compaction, and helps you select models.

## Examples

Magic Context provides powerful agent tools for memory management and recall.

**Writing to Project Memory with `ctx_memory`:**
Agents can explicitly record cross-session knowledge into specific categories.


ctx_memory(action="write", category="ARCHITECTURE", content="Event sourcing for orders.")


**Searching Across Memories, Conversations, and Git with `ctx_search`:**
Agents can query multiple layers of information simultaneously for relevant context.


ctx_search(query="why did we pick event sourcing for orders")


## Links

Explore Magic Context further through these official resources:

*   **GitHub Repository**: [https://github.com/cortexkit/magic-context](https://github.com/cortexkit/magic-context)
*   **Official Documentation**: [https://docs.cortexkit.io/magic-context](https://docs.cortexkit.io/magic-context)
*   **Desktop Application**: [https://github.com/cortexkit/magic-context/releases](https://github.com/cortexkit/magic-context/releases)