feat: added graphiti integration #76
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Change
Problem
PentAGI currently relies on vector-based semantic search (pgvector) for memory and knowledge storage. While effective for similarity matching, this approach lacks the ability to capture and query explicit relationships between entities such as tools, targets, vulnerabilities, and techniques. As a result, the system cannot answer complex questions like "What tools have been successful against Apache servers?" or "Show me the sequence of actions that led to privilege escalation."
Solution
This PR integrates Graphiti, a temporal knowledge graph system powered by Neo4j, to provide advanced semantic understanding and relationship tracking for AI agent operations. The integration uses a custom vxcontrol fork (pentagi-graphiti) that includes specialized entity and edge types for pentesting purposes.
Key Implementation Details:
Client Wrapper (
pkg/graphiti/client.go): Provides a simplified, non-blocking interface to the Graphiti API with health checks, timeout protection, and graceful degradation when disabled or unavailable.Provider Integration (
pkg/providers/performer.go): Automatically captures two types of events:Templates (
pkg/templates/graphiti/): Two templates format captured data:agent_response.tmpl: Structures agent outputs with contexttool_execution.tmpl: Captures tool details including barrier function classificationInfrastructure (
docker-compose.yml): Adds Neo4j (graph database) and Graphiti (API layer) services with proper health checks and dependencies.Configuration: Three new environment variables control the feature:
GRAPHITI_ENABLED(default: false) - Feature flagGRAPHITI_URL- Graphiti API endpointGRAPHITI_TIMEOUT- Operation timeout in secondsThe integration is designed to be completely optional and non-intrusive. When disabled or when operations fail, the system logs warnings but continues normal operation without interruption.
Closes #
Type of Change
Areas Affected
Testing and Verification
Test Configuration
Test Steps
GRAPHITI_ENABLED=truein.envfiledocker build -t graphiti-pentagi:latestdocker compose up -ddocker compose logs graphitihttp://localhost:7474and verify graph dataGRAPHITI_ENABLED=falseto verify graceful degradationTest Results
Security Considerations
New Security Requirements:
Recommendations:
NEO4J_PASSWORDin production deploymentsNo Changes To:
Performance Impact
Resource Usage:
Latency:
Documentation Updates
README.md updates
API documentation updates
Configuration documentation updates
backend/docs/config.mdGraphQL schema updates
[] Other
Deployment Notes
New Environment Variables Required:
Pre-Deployment Steps:
Build the pentagi-graphiti Docker image:
Add environment variables to
.envfileStart services:
docker compose up -dOptional Configuration:
GRAPHITI_ENABLED=false)Rollback:
GRAPHITI_ENABLED=falseto disableChecklist
Code Quality
go fmtandgo vet(for Go code)npm run lint(for TypeScript/JavaScript code)Security
Compatibility
Documentation
Additional Notes