Skip to main content

Persistent memory for LLM agents

Project description

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

from cortexgit import CortexGit
from anthropic import Anthropic

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

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

# Use it
print(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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cortexgit-0.1.0.tar.gz (38.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cortexgit-0.1.0-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file cortexgit-0.1.0.tar.gz.

File metadata

  • Download URL: cortexgit-0.1.0.tar.gz
  • Upload date:
  • Size: 38.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for cortexgit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f4f49a5fe1d8dd1bc990b8706b6e9585f3840b7e6fba932a8ca25371d31d6f94
MD5 d359571052ac565e0e0568e37e7789fa
BLAKE2b-256 ef72fb26e5d8466e0fe3ed530b393ead820ddc87c84f5a2a7d84de48b2923c28

See more details on using hashes here.

File details

Details for the file cortexgit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cortexgit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for cortexgit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02fb7ca30f4c27f5a7dd44ec1f3b17ff7cbe390e62b180f06202840fbc4afc1f
MD5 6b066d4a654f9e72d4f146b57789ceda
BLAKE2b-256 e0d1700479b2d991ebb1973767242b1c8bb03fa30a1501ebb508940f5366001d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page