-
Notifications
You must be signed in to change notification settings - Fork 47
feat(agent): implement agentic Text2GQL system with multi-stage workflow #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(agent): implement agentic Text2GQL system with multi-stage workflow #233
Conversation
…rkflow Implement comprehensive agentic text-to-graph query language system with context awareness, multi-stage validation, and self-optimization capabilities. Core Components: - DAL Layer: Query session, history, pattern, and feedback management (8 files) - Service Layer: Context tools and query context service (2 files) - Operators: 6 specialized operators for query lifecycle management * Query intention analysis and validation * Complexity analysis with index recommendations * Path pattern recognition (multi-hop, temporal, spatial) * Comprehensive query validation (schema, semantic, performance, security) * Context enhancement with user preference learning * Query design with optimization strategies - Resources: Multi-hop reasoning, query planning, and validation (3 files) - Workflow: Complete agentic text2gql configuration with 7-stage pipeline - Testing: Comprehensive test suite (22 files: unit + integration) * Unit tests for DAOs and services * Integration tests for operator collaboration and workflows Key Features: - Multi-stage workflow: understand → analyze → enhance → design → validate → execute - Context-aware query optimization with historical pattern learning - Real-time validation (schema, semantic, performance, security) - Support for complex patterns: multi-hop, temporal, spatial queries - Self-validating agentic workflow with feedback loops
qishipengqsp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the Chinese comments and file headers, aligning to the project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request implements a comprehensive agentic text-to-GQL (Graph Query Language) system with multi-stage workflow capabilities. The implementation includes a complete testing suite covering both unit and integration tests for the DAL layer, service layer, operators, and workflow orchestration.
Changes:
- Added comprehensive test coverage for QueryContextService with session, context, and history management tests (707 lines)
- Added unit tests for context management tools (ContextRetriever, PreferenceLearner, QuerySuggester) with 648 lines
- Added extensive DAL layer tests covering 4 DAO classes with full CRUD operations and edge cases
- Added integration tests for operators (QueryValidation, QueryDesign, QueryComplexityAnalysis) and workflow orchestration
- Added workflow integration tests for simple queries, error recovery, complex queries, and tool collaboration
- Created conftest.py with shared fixtures for integration tests
Reviewed changes
Copilot reviewed 38 out of 44 changed files in this pull request and generated 71 comments.
Show a summary per file
| File | Description |
|---|---|
| test/unit/core/service/test_query_context_service.py | Comprehensive unit tests for QueryContextService covering session management, context operations, and statistics |
| test/unit/core/service/test_context_tools.py | Unit tests for context tools (ContextRetriever, PreferenceLearner, QuerySuggester) with mocked service |
| test/unit/core/dal/test_query_session_dao.py | Unit tests for QuerySessionDao CRUD operations and edge cases |
| test/unit/core/dal/test_query_pattern_dao.py | Unit tests for QueryPatternDao with pattern matching and statistics |
| test/unit/core/dal/test_query_history_dao.py | Unit tests for QueryHistoryDao with query tracking and statistics |
| test/unit/core/dal/test_query_feedback_dao.py | Unit tests for QueryFeedbackDao with feedback aggregation |
| test/integration/workflow/*.py | Integration tests for simple queries, error recovery, and complex workflows |
| test/integration/orchestration/*.py | Integration tests for tool and operator collaboration patterns |
| test/integration/operator/*.py | Integration tests for validation, design, and complexity analysis operators |
| test/integration/conftest.py | Shared pytest configuration and fixtures for integration tests |
| app/plugin/tugraph/operator/init.py | Module initialization for TuGraph operators |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from app.plugin.tugraph.operator.query_validation_operator import ( | ||
| QueryValidationOperator, | ||
| create_query_validation_operator | ||
| ) |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'QueryValidationOperator' is not used.
| QueryValidationOperator, | ||
| create_query_validation_operator | ||
| ) | ||
| from app.core.model.job import SubJob |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'SubJob' is not used.
| """ | ||
|
|
||
| import pytest | ||
| from unittest.mock import AsyncMock, MagicMock, patch |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'AsyncMock' is not used.
Import of 'MagicMock' is not used.
Import of 'patch' is not used.
| """ | ||
|
|
||
| import pytest | ||
| from unittest.mock import AsyncMock, MagicMock, patch |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'AsyncMock' is not used.
Import of 'MagicMock' is not used.
Import of 'patch' is not used.
| init_server() | ||
|
|
||
| from app.core.model.job import SubJob | ||
| from app.core.model.message import WorkflowMessage |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'WorkflowMessage' is not used.
- Move example file and workflow config to test/example/ directory - Remove empty __init__.py files in test/unit/plugin/tugraph/ - Fix unused variables in example file (c2g removed, job -> _job) - Remove unused imports (Dict, Any, Expert, AgentMessage, Chat2Graph) - Add comprehensive error handling to Query Execution operator - Error categories: CONNECTION, TIMEOUT, SYNTAX, PERMISSION, RESOURCE - Retry strategy with exponential backoff for transient errors - Enhanced output schema with recovery suggestions
Summary
#231
Implement comprehensive agentic text-to-graph query language system with context awareness, multi-stage validation, and self-optimization capabilities.
Core Components:
Key Features:
Title
Type
feat: (new feature)fix: (bug fix)docs: (doc update)style: (update format)refactor: (refactor code)test: (test code)chore: (other updates)Scope
app: (Application Layer)web: (web front-end module)server: (web server module)dal: (data access layer)sdk: (sdk module)agent: (Agent Layer)reasoner: (reasoner module)planner: (planner module)workflow: (workflow module)memory: (memory module)knowledge: (knowledge module)env: (env module)toolkit: (toolkit module)system: (System Layer)plugin: (plugin module)tracer: (tracer module)resource: (resource module)none: (N/A)Description
Issue: #
Checklist
masterbranch.