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.
- 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.
- Python 3.9+
- Poetry (for dependency management)
# Clone the repository
git clone https://github.com/your-org/context-memory-persistor.git
cd context-memory-persistor
# Install dependencies
poetry install# Start the API server
poetry run uvicorn backend.api.main:app --reloadThe API will be available at http://127.0.0.1:8765. Documentation is at /docs.
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?"}'# Run unit and integration tests
poetry run pytestThe 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).
MIT