Skip to content

feat(agent): implement agentic Text2GQL system with multi-stage workflow#233

Open
SeasonPilot wants to merge 3 commits into
TuGraph-family:masterfrom
SeasonPilot:feat/agent-agentic-text2gql
Open

feat(agent): implement agentic Text2GQL system with multi-stage workflow#233
SeasonPilot wants to merge 3 commits into
TuGraph-family:masterfrom
SeasonPilot:feat/agent-agentic-text2gql

Conversation

@SeasonPilot
Copy link
Copy Markdown
Contributor

@SeasonPilot SeasonPilot commented Nov 26, 2025

Summary

#231

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

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

  • I have prepared the pull request title according to the requirements.
  • I have successfully run all unit tests and integration tests.
  • I have followed the code style guidelines of this project.
  • I have already rebased the latest master branch.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.

…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
@SeasonPilot
Copy link
Copy Markdown
Contributor Author

#231

Copy link
Copy Markdown

@qishipengqsp qishipengqsp left a 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

Comment thread test/example/agentic_text2gql_example.py
Comment thread test/example/agentic_text2gql.yml
Comment thread test/unit/plugin/tugraph/__init__.py Outdated
Comment thread test/unit/plugin/tugraph/operator/__init__.py Outdated
Comment thread test/unit/plugin/tugraph/resource/__init__.py Outdated
Comment thread test/example/agentic_text2gql.yml
Copy link
Copy Markdown

Copilot AI left a 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.

Comment thread examples/agentic_text2gql_example.py Outdated
Comment thread examples/agentic_text2gql_example.py Outdated
Comment thread examples/agentic_text2gql_example.py Outdated
Comment thread examples/agentic_text2gql_example.py Outdated
Comment thread examples/agentic_text2gql_example.py Outdated
Comment thread test/integration/operator/test_query_validation_operator.py
Comment thread test/integration/operator/test_query_validation_operator.py
Comment thread test/integration/workflow/test_simple_query_workflows.py
Comment thread test/integration/orchestration/test_tool_collaboration.py
Comment thread test/integration/orchestration/test_tool_collaboration.py
- 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
@qishipengqsp qishipengqsp changed the title feat(agent): implement agentic text-to-GQL system with multi-stage wo… feat(agent): implement agentic Text2GQL system with multi-stage workflow Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants