Skip to content

deepakdgupta1/ContextMemoryPersistor

Repository files navigation

Context Memory Persistor

AI Agent Context Management System

An advanced system for managing, persisting, and retrieving code context for AI Agents. It enables Large Language Models (LLMs) to understand and reason about large codebases effectively by providing relevant, semantically aware context.

Key Features

  • Core Analysis Engine: AST-aware parsing and chunking of Python code.
  • Dependency Graph: Tracks imports, class hierarchies, and function calls.
  • Hybrid Search: Combines Dense Retrieval (CodeBERT + FAISS) with Sparse Retrieval (BM25) using Reciprocal Rank Fusion (RRF).
  • Context Assembly: Smartly assembles context with completeness checks and dependency expansion.
  • File Watcher: Real-time monitoring of file system changes.
  • API: FastAPI-based REST interface.

Quick Start

Prerequisites

  • Python 3.9+
  • Poetry (for dependency management)

Installation

# Clone the repository
git clone https://github.com/your-org/context-memory-persistor.git
cd context-memory-persistor

# Install dependencies
poetry install

Running the Server

# Start the API server
poetry run uvicorn backend.api.main:app --reload

The API will be available at http://127.0.0.1:8765. Documentation is at /docs.

Usage

Querying Context

curl -X POST "http://127.0.0.1:8765/api/v1/context/query" \
     -H "Content-Type: application/json" \
     -d '{"query": "How is the AST parser implemented?"}'

Testing

# Run unit and integration tests
poetry run pytest

Architecture

The system is built with a Clean Architecture approach:

  • backend/analysis: Core domain logic (AST, Chunker, Graph).
  • backend/storage: Persistence adapters (SQLAlchemy, FAISS, BM25).
  • backend/search: Retrieval logic (Hybrid Search, Reranker).
  • backend/api: Entry points (FastAPI).

License

MIT

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published