wangzhigang1999 opened a new pull request, #7400: URL: https://github.com/apache/kyuubi/pull/7400
### Why are the changes needed? Part 2a of 4 for the Data Agent Engine ([umbrella](https://github.com/apache/kyuubi/issues/7379), [KPIP-7373](https://github.com/apache/kyuubi/discussions/7373)). This PR adds the tool system, data source abstraction, and composable prompt builder — the infrastructure that the agent runtime (PR 2b) will use to execute SQL and interact with the LLM. Changes include: - `AgentTool` interface with `ToolRiskLevel`, JSON schema generation for LLM function calling - `ToolRegistry` — thread-safe tool registration, dispatch, timeout enforcement, and OpenAI-compatible tool definition export - `RunSelectQueryTool` / `RunMutationQueryTool` — read-only vs. mutation SQL execution with maxRows enforcement, output truncation, and `SqlReadOnlyChecker` - `SqlExecutor` — shared JDBC execution logic with statement timeout and result formatting - `DataSourceFactory` — HikariCP connection pool creation with optional user/password - `JdbcDialect` — auto-detection from JDBC URL with dialect-specific identifier quoting (Spark, MySQL, SQLite, Trino, generic fallback) - `TableRef` — catalog/schema/table reference with JSON deserialization support - `SystemPromptBuilder` — composable Markdown prompt assembly with date injection, per-dialect datasource sections, and free-form text sections - Prompt templates: `base.md`, `datasource-{mysql,spark,sqlite,trino}.md` - New `kyuubi.engine.data.agent.tool.*` and `kyuubi.engine.data.agent.datasource.*` configuration entries ### How was this patch tested? - **Unit tests (Java)**: `JdbcDialectTest`, `TableRefTest`, `DataSourceFactoryAuthTest`, `SqlReadOnlyCheckerTest`, `RunSelectQueryToolTest`, `RunMutationQueryToolTest`, `ToolTest`, `ToolRegistryThreadSafetyTest`, `ToolSchemaGeneratorTest`, `SystemPromptBuilderTest` - **MySQL integration tests (Testcontainers)**: `DataSourceFactoryTest`, `DialectTest`, `RunSelectQueryTest`, `RunMutationQueryTest`, `ToolExecutionTest` — all run against a real MySQL container - Total: 164 JUnit tests + 21 ScalaTest tests, all passing ### Was this patch authored or co-authored using generative AI tooling? Partially assisted by Claude Code (Claude Opus 4.6) for test generation, code review, and PR formatting. Core design and implementation are human-authored. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
