Contributions are welcome! Please read the guidelines below before submitting a pull request.
# Clone the repository
git clone https://github.com/neo4j-labs/agent-memory.git
cd agent-memory/neo4j-agent-memory
# Install with uv
uv sync --group dev
# Or use the Makefile
make installThe project includes a comprehensive Makefile for common development tasks:
# Run all tests (unit + integration with auto-Docker)
make test
# Run unit tests only
make test-unit
# Run integration tests (auto-starts Neo4j via Docker)
make test-integration
# Code quality
make lint # Run ruff linter
make format # Format code with ruff
make typecheck # Run mypy type checking
make check # Run all checks (lint + typecheck + test)
# Docker management for Neo4j
make neo4j-start # Start Neo4j container
make neo4j-stop # Stop Neo4j container
make neo4j-logs # View Neo4j logs
make neo4j-clean # Stop and remove volumes
# Run examples
make example-basic # Basic usage example
make example-resolution # Entity resolution example
make example-langchain # LangChain integration example
make example-pydantic # Pydantic AI integration example
make examples # Run all examples
# Full-stack chat agent
make chat-agent-install # Install backend + frontend dependencies
make chat-agent-backend # Run FastAPI backend (port 8000)
make chat-agent-frontend # Run Next.js frontend (port 3000)
make chat-agent # Show setup instructionsExamples are located in examples/ and demonstrate various features:
| Example | Description | Requirements |
|---|---|---|
lennys-memory/ |
Flagship demo: Podcast knowledge graph with AI chat, graph visualization, map view, entity enrichment | Neo4j, OpenAI, Node.js |
financial-services-advisor/ |
AWS Strands demo: Multi-agent KYC/AML compliance with 5 specialized agents, CDK deployment | Neo4j Aura, AWS Bedrock, Node.js |
full-stack-chat-agent/ |
Full-stack web app with FastAPI backend and Next.js frontend | Neo4j, OpenAI, Node.js |
basic_usage.py |
Core memory operations (short-term, long-term, reasoning) | Neo4j, OpenAI API key |
entity_resolution.py |
Entity matching strategies | None |
langchain_agent.py |
LangChain integration | Neo4j, OpenAI, langchain extra |
pydantic_ai_agent.py |
Pydantic AI integration | Neo4j, OpenAI, pydantic-ai extra |
domain-schemas/ |
GLiNER2 domain schema examples (8 domains) | GLiNER extra, optional Neo4j |
Examples load environment variables from examples/.env. Copy the template:
cp examples/.env.example examples/.env
# Edit examples/.env with your settingsKey variables:
NEO4J_URI- If set, uses this Neo4j; if not set, auto-starts DockerNEO4J_PASSWORD- Neo4j password (test-passwordfor Docker)OPENAI_API_KEY- Required for OpenAI embeddings and LLM extraction
# Run with your own Neo4j (uses NEO4J_URI from .env)
make example-basic
# Or without .env (auto-starts Docker Neo4j)
rm examples/.env # Ensure no .env file
make example-basic # Will start Docker with test-password# Control integration test behavior
RUN_INTEGRATION_TESTS=1 # Enable integration tests
SKIP_INTEGRATION_TESTS=1 # Skip integration tests
AUTO_START_DOCKER=1 # Auto-start Neo4j via Docker (default: true)
AUTO_STOP_DOCKER=1 # Auto-stop Neo4j after tests (default: false)# Keep Neo4j running after tests (useful for debugging)
./scripts/run-integration-tests.sh --keep
# Run with verbose output
./scripts/run-integration-tests.sh --verbose
# Run specific test pattern
./scripts/run-integration-tests.sh --pattern "test_short_term"# Unit tests (fast, no external dependencies)
pytest tests/unit -v
# Integration tests (requires Neo4j)
pytest tests/integration -v
# Example validation tests
pytest tests/examples -v
# All tests with coverage
pytest --cov=neo4j_agent_memory --cov-report=htmlThis project uses GitHub Actions for continuous integration and deployment.
| Workflow | Trigger | Purpose |
|---|---|---|
CI (ci.yml) |
Push to main, PRs |
Linting, type checking, tests, build validation |
Release (release.yml) |
Git tags (v*) |
Build and publish to PyPI, create GitHub releases |
- Lint - Code quality checks using Ruff (
ruff check+ruff format --check) - Type Check - Static type analysis using mypy on
src/ - Unit Tests - Python 3.10, 3.11, 3.12, 3.13 with coverage (uploaded to Codecov)
- Integration Tests - Neo4j 5.26 via GitHub Actions services, matrix across Python versions
- Example Tests - Quick validation (no Neo4j) + full validation (with Neo4j)
- Build - Package build validation, wheel/sdist, install + import check
Before submitting a PR, run the same checks locally:
# Run all checks (recommended before PR)
make ci
# Or run individual checks:
make lint # Ruff linting
make format # Auto-format code
make typecheck # Mypy type checking
make test # Unit tests only
make test-all # Unit + integration testsAll PRs must pass these checks before merging:
- Lint (ruff check)
- Format (ruff format)
- Unit tests (all Python versions)
- Integration tests
- Build validation
- Formatter: Ruff (line length: 88)
- Linter: Ruff
- Type Checker: mypy (strict mode)
- Docstrings: Google style
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes
- Run
make cito validate - Commit with descriptive messages
- Push and open a PR against
main
- Update version in
pyproject.toml - Create and push a tag:
git tag v0.1.0 git push origin v0.1.0
- GitHub Actions will automatically build and publish to PyPI
The documentation follows the Diataxis framework, which organizes content into four distinct types based on user needs:
| Type | Purpose | User Need | Location |
|---|---|---|---|
| Tutorials | Learning-oriented | "I want to learn" | docs/tutorials/ |
| How-To Guides | Task-oriented | "I want to accomplish X" | docs/how-to/ |
| Reference | Information-oriented | "I need to look up Y" | docs/reference/ |
| Explanation | Understanding-oriented | "I want to understand why" | docs/explanation/ |
- New public API? --> Update
docs/reference/with method signatures - New user-facing feature? --> Add how-to guide in
docs/how-to/ - Major new capability? --> Consider adding a tutorial in
docs/tutorials/ - Architectural change? --> Add explanation in
docs/explanation/ - Code examples compile? --> Run
make test-docs-syntax
# Build documentation locally
cd docs && npm install && npm run build
# Preview documentation
cd docs && npm run serve
# Run documentation tests
make test-docs # All doc tests
make test-docs-syntax # Validate Python code snippets compile
make test-docs-build # Test build pipeline
make test-docs-links # Validate internal linksIs this about learning a concept from scratch?
--> Yes: Tutorial (docs/tutorials/)
--> No:
Is this about accomplishing a specific task?
--> Yes: How-To Guide (docs/how-to/)
--> No:
Is this describing what something is or how to use it?
--> Yes: Reference (docs/reference/)
--> No:
Is this explaining why something works the way it does?
--> Yes: Explanation (docs/explanation/)