Skip to main content

CortexGit

Persistent memory for LLM agents. Event sourcing + semantic retrieval.

The Problem

LLM agents are stateless. They forget context between sessions. They can't coordinate without explicit message passing. They have no audit trail.

The Solution

CortexGit is an in-process memory system. Write events, retrieve context, persist facts. Works with any LLM, any agent framework.

Installation

pip install cortexgit

Quick Start

import asyncio
from cortexgit import CortexGit
from anthropic import Anthropic

# Initialize memory (creates local SQLite database)
memory = CortexGit()
client = Anthropic()

async def my_agent(user_query):
    session_id = "session-1"
    agent_id = "my-agent"
    
    # Retrieve relevant context from memory
    context = await memory.get_context(
        goal=user_query,
        budget_tokens=4000,
        session_id=session_id
    )
    
    # Call Claude with context
    response = await client.messages.create(
        model="claude-sonnet-4-20250514",
        max_tokens=1024,
        system=f"You are a helpful agent. Memory: {context}",
        messages=[{"role": "user", "content": user_query}]
    )
    
    # Remember what happened
    await memory.log_event(
        session_id=session_id,
        agent_id=agent_id,
        event_type="agent",
        payload={"query": user_query, "response": response.content[0].text}
    )
    
    return response.content[0].text

# Use it
print(asyncio.run(my_agent("What is 2+2?")))

Documentation

Configuration

By default, CortexGit uses SQLite (sqlite+aiosqlite:///cortexgit.db) which requires no external server or setup.

To use PostgreSQL in production:

  1. Install PostgreSQL and create a database (e.g. cortexgit).
  2. Set the DATABASE_URL environment variable:
    DATABASE_URL="postgresql+asyncpg://postgres:password@localhost:5432/cortexgit"
    

Features

  • ✅ Append-only event log (source of truth)
  • ✅ Persistent entity registry with conflict detection
  • ✅ Automatic snapshot generation
  • ✅ Semantic retrieval over compressed memory
  • ✅ Works with any LLM (Claude, GPT, local models)
  • ✅ Single import, no server needed

License

MIT

Metadata

Release files for cortexgit 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cortexgit 0.2.1
File Size Uploaded Provenance
cortexgit-0.2.1.tar.gz 84.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cortexgit 0.2.1
File Interpreter ABI Platform
cortexgit-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 126.7 kB

Release files / cortexgit-0.2.1.tar.gz

Download URL cortexgit-0.2.1.tar.gz
Size 84.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7cc3237be0501c91e90852b12584bd8fa221f01ddc0ca9b7d087239ab898721c
BLAKE2b-256 checksum
How to use checksums
9914ee3faa8e9f4ee55431b18cf36dfff02c99a46826ddc24c05437ceab375aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / cortexgit-0.2.1-py3-none-any.whl

Download URL cortexgit-0.2.1-py3-none-any.whl
Size 42.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e4e85be3f5c4ba6573bcf5249b88ba6cfc23fde4e68f298158e9d366f1689bd
BLAKE2b-256 checksum
How to use checksums
9a46dbcd8d871849957b60f9000853d5517b078aa919f3f160f5d9c1e3f133db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for cortexgit 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page