Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ on:
- "integrations/langchain-memgraph/**"
- "integrations/lightrag-memgraph/**"
- "unstructured2graph/**"
- "enterprise-context/agent-memory/**"
pull_request:
paths:
- "memgraph-toolbox/**"
- "integrations/mcp-memgraph/**"
- "integrations/langchain-memgraph/**"
- "integrations/lightrag-memgraph/**"
- "unstructured2graph/**"
- "enterprise-context/agent-memory/**"

jobs:
changes:
Expand All @@ -27,6 +29,7 @@ jobs:
langchain-memgraph: ${{ steps.filter.outputs.langchain-memgraph }}
lightrag-memgraph: ${{ steps.filter.outputs.lightrag-memgraph }}
unstructured2graph: ${{ steps.filter.outputs.unstructured2graph }}
agent-memory: ${{ steps.filter.outputs.agent-memory }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -50,6 +53,8 @@ jobs:
unstructured2graph:
- 'unstructured2graph/**'
- 'memgraph-toolbox/**'
agent-memory:
- 'enterprise-context/agent-memory/**'

test-memgraph-toolbox:
needs: changes
Expand Down Expand Up @@ -187,3 +192,61 @@ jobs:
uv venv
uv pip install -e .[test]
.venv/bin/python -m pytest .

test-agent-memory-cognee:
needs: changes
if: ${{ needs.changes.outputs.agent-memory == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11.0

- name: Start Memgraph container
run: |
docker run -d -p 7687:7687 --name memgraph memgraph/memgraph-mage:latest --schema-info-enabled=True --telemetry-enabled=false
sleep 5

- name: Install uv
run: python -m pip install uv

- name: Install dependencies and run tests
working-directory: enterprise-context/agent-memory
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
uv venv
uv pip install -e .[cognee]
.venv/bin/python -m pytest -m cognee -v

test-agent-memory-neo4j:
needs: changes
if: ${{ needs.changes.outputs.agent-memory == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11.0

- name: Start Memgraph container
run: |
docker run -d -p 7687:7687 --name memgraph memgraph/memgraph-mage:latest --schema-info-enabled=True --telemetry-enabled=false
sleep 5

- name: Install uv
run: python -m pip install uv

- name: Install dependencies and run tests
working-directory: enterprise-context/agent-memory
run: |
uv venv
uv pip install -e .[neo4j-agent-memory]
.venv/bin/python -m pytest -m neo4j_agent_memory -v
22 changes: 22 additions & 0 deletions enterprise-context/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Virtual environments
.venv/
venv/

# Python
__pycache__/
*.py[cod]
*.egg-info/
dist/
build/

# IDE
.idea/
*.swp
*.swo

# OS
.DS_Store
Thumbs.db

# Environment
.env
24 changes: 24 additions & 0 deletions enterprise-context/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Enterprise Context

A collection of standalone components for enriching enterprise data with graph-powered context. Each component is an independent library or CLI tool with its own dependencies and configuration.

## Components

| Component | Description |
| ------------------------------ | ---------------------------------------------------------------------------------------- |
| [sic-agent](./sic-agent) | SIC Classification MCP Server using Memgraph vector search |
| [agent-memory](./agent-memory) | Integration tests for memory frameworks (Cognee, Mem0, neo4j-agent-memory) with Memgraph |

## Structure

Each component lives in its own subdirectory and includes:

- `pyproject.toml` — project metadata and dependencies
- `README.md` — component-specific documentation
- `LICENSE` — license file

Components are independent and can be installed/run separately.

## Getting Started

Navigate into any component directory and follow its README for setup instructions.
21 changes: 21 additions & 0 deletions enterprise-context/agent-memory/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Memgraph

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
49 changes: 49 additions & 0 deletions enterprise-context/agent-memory/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Agent Memory Tests

Integration tests for memory frameworks with Memgraph. Each test suite validates that a memory framework works correctly using Memgraph as its graph backend.

## Frameworks

| Framework | Description | Upstream |
| ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------- |
| [Cognee](https://github.com/topoteretes/cognee-community/tree/main/packages/graph/memgraph) | Knowledge graph adapter for the Cognee framework | `cognee-community-graph-adapter-memgraph` |
| [Neo4j Agent Memory](https://github.com/neo4j-labs/agent-memory) | Graph-native memory system for AI agents (testing Bolt-compatibility with Memgraph) | `neo4j-agent-memory` |

## Prerequisites

- Python >= 3.10
- A running Memgraph instance (default: `bolt://localhost:7687`)

```bash
docker run -p 7687:7687 memgraph/memgraph-mage:latest --schema-info-enabled=True
```

## Setup

Install all test dependencies:

```bash
uv sync --all-extras
```

Or install only a specific framework:

```bash
uv sync --extra cognee
uv sync --extra neo4j-agent-memory
```

## Running Tests

Run all tests:

```bash
uv run pytest
```

Run tests for a specific framework:

```bash
uv run pytest -m cognee
uv run pytest -m neo4j_agent_memory
```
39 changes: 39 additions & 0 deletions enterprise-context/agent-memory/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[project]
name = "agent-memory-tests"
version = "0.1.0"
description = "Integration tests for memory frameworks with Memgraph"
readme = "README.md"
license = { text = "MIT" }
requires-python = ">=3.10"

dependencies = [
"pytest>=8.0.0",
"pytest-asyncio>=0.23.0",
"neo4j>=5.20.0",
]

[project.optional-dependencies]
cognee = [
"cognee-community-graph-adapter-memgraph>=0.1.0",
]
neo4j-agent-memory = [
"neo4j-agent-memory>=0.1.0",
]
all = [
"agent-memory-tests[cognee,neo4j-agent-memory]",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["tests"]

[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = ["tests"]
markers = [
"cognee: tests for the cognee integration with Memgraph",
"neo4j_agent_memory: tests for the neo4j-agent-memory integration with Memgraph",
]
Empty file.
79 changes: 79 additions & 0 deletions enterprise-context/agent-memory/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import os

import pytest
from neo4j import GraphDatabase

MEMGRAPH_URL = os.environ.get("MEMGRAPH_URL", "bolt://localhost:7687")
MEMGRAPH_USERNAME = os.environ.get("MEMGRAPH_USERNAME", "")
MEMGRAPH_PASSWORD = os.environ.get("MEMGRAPH_PASSWORD", "")


@pytest.fixture(scope="session")
def memgraph_url():
return MEMGRAPH_URL


@pytest.fixture(scope="session")
def memgraph_username():
return MEMGRAPH_USERNAME


@pytest.fixture(scope="session")
def memgraph_password():
return MEMGRAPH_PASSWORD


@pytest.fixture(scope="session")
def memgraph_driver():
"""Shared neo4j driver for direct Cypher assertions."""
driver = GraphDatabase.driver(
MEMGRAPH_URL, auth=(MEMGRAPH_USERNAME, MEMGRAPH_PASSWORD)
)
yield driver
driver.close()


def _node_count(driver) -> int:
with driver.session() as session:
return session.run("MATCH (n) RETURN count(n) AS cnt").single()["cnt"]


def _relationship_count(driver) -> int:
with driver.session() as session:
return session.run("MATCH ()-[r]->() RETURN count(r) AS cnt").single()["cnt"]


@pytest.fixture()
def assert_graph_not_empty(memgraph_driver):
"""Return a callable that asserts Memgraph contains nodes after the framework writes."""

def _check(*, min_nodes: int = 1, min_relationships: int = 0):
nodes = _node_count(memgraph_driver)
rels = _relationship_count(memgraph_driver)
assert (
nodes >= min_nodes
), f"Expected at least {min_nodes} node(s) in Memgraph, found {nodes}"
assert (
rels >= min_relationships
), f"Expected at least {min_relationships} relationship(s) in Memgraph, found {rels}"

return _check


@pytest.fixture()
def run_cypher(memgraph_driver):
"""Return a callable that executes an arbitrary Cypher query and returns records."""

def _run(query: str, **params):
with memgraph_driver.session() as session:
return list(session.run(query, **params))

return _run


@pytest.fixture(autouse=True)
def _clean_memgraph(memgraph_driver):
"""Wipe all data before each test so tests are isolated."""
with memgraph_driver.session() as session:
session.run("MATCH (n) DETACH DELETE n")
yield
Loading
Loading