Post

OpenContext - Give Your AI Assistant a Persistent Memory for Multi-Agent Workflows

πŸ€” Curiosity: How Can We Give AI Agents Persistent Memory?

When building AI-powered applications, one recurring frustration stands out: context gets lost. Every new chat, every session restart, every repo switch β€” the AI forgets everything. You end up re-explaining your project background, repeating architectural decisions, and sometimes the assistant makes wrong assumptions because it lacks historical context.

Curiosity: What if AI agents could remember your project decisions, technical constraints, and domain knowledge across sessions, repos, and tools? How would that transform the multi-agent development workflow?

Core Question: Can we create a unified context store that works across Cursor, Claude Code, Codex, and other AI coding assistants?


πŸ“š Retrieve: Understanding OpenContext

The Problem

Before OpenContextAfter OpenContext
πŸ“‚ Hard to share context across repos/sessionsβœ… Global context library works across all projects
🀷 Your ideas can’t be quickly perceived by Agentβœ… Agent loads your background & decisions automatically
πŸ”’ Existing knowledge can’t be operated by Coding Agentβœ… Agent can directly read/write your knowledge base

What is OpenContext?

OpenContext is a lightweight personal context/knowledge store for AI assistants and coding tools. It enables the paradigm:

β€œLoad history first, then act; ship, then persist.”

The tool provides:

  • oc CLI β€” manage a global contexts/ library (folders/docs, manifests, search)
  • MCP Server β€” so Cursor/Claude Code/Codex/Agents can call OpenContext as tools
  • Skills + Slash Commands β€” user-level skills for Cursor/Claude Code/Codex
  • Desktop App β€” manage/search/edit contexts with a native UI
  • Web UI β€” browse/edit contexts locally (no install required)

Multi-Agent Integration Architecture

graph TB
    subgraph OpenContext["OpenContext Multi-Agent System"]
        A[User Context] --> B[OpenContext Store]

        B --> C[Cursor Agent]
        B --> D[Claude Code Agent]
        B --> E[Codex Agent]
        B --> F[Custom MCP Agents]

        C --> C1[opencontext-context]
        C --> C2[opencontext-search]
        C --> C3[opencontext-create]
        C --> C4[opencontext-iterate]

        D --> D1[Context Loading]
        D --> D2[Knowledge Search]
        D --> D3[Doc Creation]
        D --> D4[Insight Persistence]

        E --> E1[Skill-based Access]
        E --> E2[Tool Integration]

        F --> F1[MCP Protocol]
        F --> F2[Custom Tools]

        C1 --> G[Shared Knowledge Base]
        C2 --> G
        D1 --> G
        D2 --> G
        E1 --> G
        F1 --> G

        G --> H[Persistent AI Memory]
    end

    style B fill:#ff6b6b,stroke:#c92a2a,stroke-width:3px,color:#fff
    style G fill:#4ecdc4,stroke:#0a9396,stroke-width:2px,color:#fff
    style H fill:#ffe66d,stroke:#f4a261,stroke-width:2px,color:#000

πŸ’‘ Innovation: Setting Up Multi-Agent Context Management

Quick Start (30 Seconds)

1
2
3
4
5
6
7
8
9
10
11
12
# 1. Install CLI
npm install -g @aicontextlab/cli

# 2. Initialize (prompts for tool setup; defaults to all)
cd your-project
oc init

# 3. Use slash commands (Cursor + Claude Code)
# /opencontext-context β€” load background before working
# /opencontext-search β€” find relevant docs
# /opencontext-create β€” create a new doc
# /opencontext-iterate β€” persist what you learned

Installed Components by oc init

ComponentLocationPurpose
Cursor Commands~/.cursor/commandsSlash commands for context operations
Claude Code Commands~/.claude/commandsSlash commands integration
Cursor Skills~/.cursor/skills/opencontext-*/SKILL.mdUser-level skill definitions
Claude Code Skills~/.claude/skills/opencontext-*/SKILL.mdSkill-based context access
Codex Skills~/.codex/skills/opencontext-*/SKILL.mdCodex skill integration
MCP Config~/.cursor/mcp.json, ~/.claude/mcp.jsonMCP server configuration

CLI Commands Reference

CommandWhat it does
oc initInitialize OpenContext + user-level tool integrations
oc folder lsList folders
oc folder create <path> -d "desc"Create a folder
oc doc create <folder> <name>.md -d "desc"Create a document
oc doc ls <folder>List documents
oc context manifest <folder>Generate file list for AI to read
oc search "query"Search documents
oc mcpStart MCP server for MCP clients
oc uiStart local Web UI

πŸ› οΈ Integrating with Multi-Agent Workflows

Workflow Pattern: Context-First Development

flowchart LR
    subgraph BeforeWork["Before Work"]
        A1[opencontext-context]
        A2[Load project background]
    end

    subgraph DuringWork["During Work"]
        B1[opencontext-search]
        B2[Search existing conclusions]
    end

    subgraph AfterWork["After Work"]
        C1[opencontext-iterate]
        C2[Record decisions]
    end

    A1 --> A2
    A2 --> B1
    B1 --> B2
    B2 --> C1
    C1 --> C2
    C2 -.-> A1

    style A1 fill:#ff6b6b,stroke:#c92a2a,stroke-width:2px,color:#fff
    style B1 fill:#4ecdc4,stroke:#0a9396,stroke-width:2px,color:#fff
    style C1 fill:#ffe66d,stroke:#f4a261,stroke-width:2px,color:#000

Slash Commands Deep Dive

CommandDescriptionBest For
/opencontext-helpNot sure which to use? Start hereNew users
/opencontext-context(Safe default) Load background before workingStarting any task
/opencontext-searchDiscover existing docs (no auto index build)Finding prior decisions
/opencontext-createDraft a new doc/ideaCapturing new knowledge
/opencontext-iteratePersist conclusions & citationsEnding sessions

Pro tip: Persist β€œacceptance criteria / common pitfalls / API contracts / dependency versions” as docs β€” highest ROI.


πŸ“Š Desktop App Features

For visual users who prefer a native UI:

Key Capabilities

  1. Create folders and docs β€” Organize by project or topic
  2. Search with Cmd/Ctrl + K β€” Searches titles, descriptions, and content
  3. Semantic search β€” Configure API Key in Settings β†’ Embedding (auto-indexed)
  4. Cite to agents β€” Copy citations directly to Cursor/Claude/Agent

Citation Options

ActionStepsEffect
Cite text snippetSelect text β†’ Right-click β†’ β€œCopy Citation”Agent reads snippet + source
Cite documentClick citation icon next to doc titleAgent gets full doc + stable_id
Cite folderRight-click folder β†’ β€œCopy Folder Citation”Agent batch-reads all docs inside

πŸ”§ Search Configuration

Search Modes

ModeFlagRequirements
Keyword--mode keywordNo embeddings needed
Vector--mode vectorRequires embeddings + index
Hybrid--mode hybridRequires embeddings + index (default)

Enabling Semantic Search (CLI)

1
2
3
4
5
6
7
8
9
10
11
# 1. Set API Key
oc config set EMBEDDING_API_KEY "<your_key>"

# 2. (Optional) Set base URL
oc config set EMBEDDING_API_BASE "https://api.openai.com/v1"

# 3. (Optional) Set Model
oc config set EMBEDDING_MODEL "text-embedding-3-small"

# 4. Build Index
oc index build

Warning: The oc index build command may use paid APIs. AI assistants are NOT allowed to auto-run it by default.


πŸ€– MCP Server Integration

OpenContext runs as a standard MCP (Model Context Protocol) server using stdio:

1
2
3
4
5
6
7
# Start manually
oc mcp

# User-level config locations:
# - Cursor: ~/.cursor/mcp.json
# - Claude Code: ~/.claude/mcp.json
# - Codex: ~/.codex/mcp.json

Example mcp.json Configuration

1
2
3
4
5
6
7
8
{
  "mcpServers": {
    "opencontext": {
      "command": "npx",
      "args": ["@aicontextlab/cli", "mcp"]
    }
  }
}

πŸ“ˆ Performance Comparison: With vs Without Context Store

MetricWithout OpenContextWith OpenContextImprovement
Context Re-explanationEvery sessionOnce⬇️ 95%
Decision ConsistencyVariableTracked⬆️ High
Cross-repo KnowledgeManualAutomatic⬆️ Seamless
Onboarding TimeHours per projectMinutes⬇️ 80%
Agent AccuracyContext-limitedContext-enriched⬆️ Significant

🎯 Best Practices for Multi-Agent Context

What to Persist

Document TypeExample ContentROI
Acceptance CriteriaFeature requirements, success metrics⭐⭐⭐
Common PitfallsKnown bugs, edge cases, gotchas⭐⭐⭐
API ContractsEndpoint specs, data formats⭐⭐
Dependency VersionsLock file summaries, upgrade notes⭐⭐
Architecture DecisionsADRs, design rationale⭐⭐
Domain KnowledgeBusiness logic, terminology⭐⭐⭐

Folder Organization Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
~/.opencontext/contexts/
β”œβ”€β”€ personal/
β”‚   β”œβ”€β”€ preferences.md
β”‚   └── coding-style.md
β”œβ”€β”€ project-frontend/
β”‚   β”œβ”€β”€ architecture.md
β”‚   β”œβ”€β”€ component-patterns.md
β”‚   └── known-issues.md
β”œβ”€β”€ project-backend/
β”‚   β”œβ”€β”€ api-design.md
β”‚   β”œβ”€β”€ database-schema.md
β”‚   └── deployment-notes.md
└── shared/
    β”œβ”€β”€ team-conventions.md
    └── dependency-policies.md

πŸš€ Environment Configuration

Default Paths

PurposeDefault Location
Contexts~/.opencontext/contexts
Database~/.opencontext/opencontext.db

Override with Environment Variables

1
2
export OPENCONTEXT_CONTEXTS_ROOT="/path/to/contexts"
export OPENCONTEXT_DB_PATH="/path/to/opencontext.db"

πŸ€” New Questions This Raises

  1. Automatic Context Extraction: Can agents automatically identify and persist important decisions from conversations?
  2. Context Versioning: How do we handle context evolution and maintain historical snapshots?
  3. Team Collaboration: Can multiple developers share and sync context across a team?
  4. Domain-Specific Templates: What context structures work best for different project types (web app, mobile, ML, etc.)?
  5. Context Quality: How do we measure and improve the quality of persisted context?

Next Experiment: Building automated context extraction from conversation history using multi-agent orchestration.


References

Official Resources:

Related Tools & Frameworks:

Multi-Agent Systems:

Context Management Research:

Production Resources:

This post is licensed under CC BY 4.0 by the author.