Skip to content

feat: Refactor AI Assistant to Agent with Pydantic-AI and MCP support#1209

Merged
Teingi merged 32 commits intooceanbase:masterfrom
wayyoungboy:430-obdiag-agent
Mar 19, 2026
Merged

feat: Refactor AI Assistant to Agent with Pydantic-AI and MCP support#1209
Teingi merged 32 commits intooceanbase:masterfrom
wayyoungboy:430-obdiag-agent

Conversation

@wayyoungboy
Copy link
Copy Markdown
Member

Changes

  • Refactor AI Assistant into a Pydantic-AI-based Agent
  • Add obdiag agent command with interactive and single-shot modes
  • Introduce MCP toolset (config_gen, database, file_ops, obdiag, sql_validator)
  • Unify config path handling via obdiag_path
  • Minor gather enhancements and bug fixes

wayyoungboy and others added 30 commits March 2, 2026 17:31
…ndler

- close oceanbase#1054
- Introduced a new method `_deduplicate_parse_tables` to eliminate duplicate table entries in SQL parsing, ensuring that each table is processed only once even if referenced multiple times.
- Updated existing methods to utilize the deduplication logic, improving efficiency in schema reporting and statistics gathering.
…ndler

- close oceanbase#1054
- Introduced a new method `__append_create_table_sql` to append CREATE TABLE DDL statements to a designated SQL file for direct execution.
- Updated the `__print_result` method to include the path of the newly created SQL file in the output summary.
- Initialized `create_tables_sql_file` attribute to store the SQL file path based on the gather timestamp.
- Renamed AI Assistant to Agent across the codebase, including method names and command classes.
- Updated `pyproject.toml` to include `pydantic-ai-slim` as a dependency.
- Modified README files to reflect the new command name and its functionalities.
- Introduced a new configuration structure for the agent in `ai.yml`.
- Added new files for agent handling, configuration management, and MCP server/client integration.
- Enhanced the agent's capabilities for interactive diagnostics and multi-cluster support.
- Updated various modules to replace hardcoded paths with the obdiag_path utility for better path management.
- Refactored config file handling in ConfigHelper, ConfigManager, and MCPServer to ensure consistent usage of workspace paths.
- Enhanced error handling and path expansion for configuration and log directories across the codebase.
- Improved maintainability by centralizing path logic in the constant module.
- Introduced a new configuration file `agent.yml.example` to replace the deprecated `ai.yml.example`, providing clearer setup instructions for the obdiag agent.
- Updated installation scripts to copy the new configuration file to the appropriate directory.
- Modified various components to reference the new configuration path, ensuring compatibility with the updated structure.
- Enhanced user experience guidelines in the agent's command handling, including clearer instructions for log gathering and session management.
- Added session persistence features, allowing users to save and resume diagnostic sessions.
- Improved command execution logic for better handling of tool-related messages and outputs.
- Introduced a new dependency on `pydantic-ai-skills` to enable skills functionality.
- Updated `agent.yml.example` to include skills configuration options.
- Enhanced the `AgentConfig` model to support skills settings such as directory, validation, and script timeout.
- Implemented a `_build_skills_toolset` function to load skills from the specified directory when enabled.
- Integrated skills handling into the agent creation process, allowing for dynamic instruction injection based on available skills.
* Enhancement: Add deduplication of parse tables in GatherPlanMonitorHandler

- close oceanbase#1054
- Introduced a new method `_deduplicate_parse_tables` to eliminate duplicate table entries in SQL parsing, ensuring that each table is processed only once even if referenced multiple times.
- Updated existing methods to utilize the deduplication logic, improving efficiency in schema reporting and statistics gathering.

* Enhancement: Append CREATE TABLE DDL to SQL file in GatherTableDumpHandler

- close oceanbase#1054
- Introduced a new method `__append_create_table_sql` to append CREATE TABLE DDL statements to a designated SQL file for direct execution.
- Updated the `__print_result` method to include the path of the newly created SQL file in the output summary.
- Initialized `create_tables_sql_file` attribute to store the SQL file path based on the gather timestamp.

* update

* fix: SQLTableExtractor comma join and filter invalid refs

* fix(check): bug_469 glibc check - skip by default, only check affected OB version ranges
* Enhancement: Add deduplication of parse tables in GatherPlanMonitorHandler

- close oceanbase#1054
- Introduced a new method `_deduplicate_parse_tables` to eliminate duplicate table entries in SQL parsing, ensuring that each table is processed only once even if referenced multiple times.
- Updated existing methods to utilize the deduplication logic, improving efficiency in schema reporting and statistics gathering.

* Enhancement: Append CREATE TABLE DDL to SQL file in GatherTableDumpHandler

- close oceanbase#1054
- Introduced a new method `__append_create_table_sql` to append CREATE TABLE DDL statements to a designated SQL file for direct execution.
- Updated the `__print_result` method to include the path of the newly created SQL file in the output summary.
- Initialized `create_tables_sql_file` attribute to store the SQL file path based on the gather timestamp.

* update

* fix: SQLTableExtractor comma join and filter invalid refs

* fix(gather_plan_monitor): use user tenant connection for database validation

__validate_database uses sys_connector to query information_schema.SCHEMATA,
but this view is tenant-scoped in OceanBase. Sys tenant only sees sys schemas,
so user databases (e.g. ad_marketing in t_ad_marketing) fail validation.

Fix: Use user tenant connection (db_conn) for validation instead. Create a
temporary OBConnector with db_conn credentials (database=None to avoid
connection failure when database is wrong), then query SCHEMATA.

Made-with: Cursor
- Introduced a new configuration file `agent.yml.example` to replace the deprecated `ai.yml.example`, providing clearer setup instructions for the obdiag agent.
- Updated installation scripts to copy the new configuration file to the appropriate directory.
- Modified various components to reference the new configuration path, ensuring compatibility with the updated structure.
- Enhanced user experience guidelines in the agent's command handling, including clearer instructions for log gathering and session management.
- Added session persistence features, allowing users to save and resume diagnostic sessions.
- Improved command execution logic for better handling of tool-related messages and outputs.
- Introduced a new dependency on `pydantic-ai-skills` to enable skills functionality.
- Updated `agent.yml.example` to include skills configuration options.
- Enhanced the `AgentConfig` model to support skills settings such as directory, validation, and script timeout.
- Implemented a `_build_skills_toolset` function to load skills from the specified directory when enabled.
- Integrated skills handling into the agent creation process, allowing for dynamic instruction injection based on available skills.
style(tools): clean up whitespace and formatting
Copy link
Copy Markdown
Member

@Teingi Teingi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Teingi Teingi merged commit f01bf5c into oceanbase:master Mar 19, 2026
17 checks passed
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.

2 participants