wangzhigang1999 opened a new pull request, #7417: URL: https://github.com/apache/kyuubi/pull/7417
### Why are the changes needed? Part 2b 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 ReAct agent runtime that drives the LLM <-> tool loop, a composable middleware stack around it, and a production `OpenAiProvider`. It sits on top of the tool system and data source abstraction introduced in PR 2a, and is consumed by the REST layer in PR 3. Changes include: - `ReactAgent` — ReAct loop with streaming, tool-call dispatch, turn budget, malformed-tool-call recovery - `ConversationMemory` — message history with cumulative prompt-token tracking - `AgentRunContext` / `AgentInvocation` / `ApprovalMode` — per-run state plumbing - `ToolOutputStore` — size-gated tool-output offload, keyed by session+call-id, with `ReadToolOutputTool` / `GrepToolOutputTool` for LLM-driven retrieval - `AgentMiddleware` interface with `onRegister` hook for tool wiring, plus four middlewares: - `LoggingMiddleware` — structured request/response logging - `ApprovalMiddleware` — risk-level-based approval gate - `CompactionMiddleware` — token-threshold-driven history summarization keyed by session - `ToolResultOffloadMiddleware` — transparently owns the `ToolOutputStore` and registers retrieval tools - `OpenAiProvider` — OpenAI-compatible chat completions with streaming and tool calls - Dialects moved under `datasource.dialect` package for organization - New `kyuubi.engine.data.agent.compaction.trigger.tokens` configuration entry - `MockLlmProvider` — deterministic mock for middleware and runtime tests ### How was this patch tested? - **Unit tests (Java)**: `AgentInvocationTest`, `AgentMiddlewareTest`, `AgentRunContextTest`, `ConversationMemoryTest`, `LoggingMiddlewareTest`, `ReactAgentBuilderTest`, `ToolOutputStoreTest`, `ApprovalMiddlewareTest`, `CompactionMiddlewareTest`, `ToolResultOffloadMiddlewareTest` - **Live LLM tests** (opt-in, require `OPENAI_API_KEY`): `ReactAgentLiveTest`, `CompactionMiddlewareLiveTest` — exercise the full loop against a real OpenAI-compatible endpoint - **E2E**: `DataAgentE2ESuite` extended with OpenAI-provider paths - Existing unit + MySQL Testcontainers tests from PR 2a remain green ### Was this patch authored or co-authored using generative AI tooling? Partially assisted by Claude Code (Claude Opus 4.7) 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]
