refactor(acp): delegate prompt turn processing logic to GeminiClient#26222
refactor(acp): delegate prompt turn processing logic to GeminiClient#26222
Conversation
|
Hi @sripasg, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this. We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines. Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed. Thank you for your understanding and for being a part of our community! |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the ACP session prompt processing logic to delegate directly to the GeminiClient. By moving away from low-level chat module calls, the implementation now benefits from centralized core features such as chat compression, context validation, and improved execution tracing. Additionally, the update introduces better telemetry tracking and robust error handling for stream interactions. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
Size Change: +2.16 kB (+0.01%) Total Size: 33.9 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
This pull request refactors the session handling logic in acpSession.ts and updates the corresponding tests to support new Gemini event types and improved stream processing. The changes introduce a loop-based turn management system and update the client interaction pattern. I have identified a critical issue regarding the missing GeminiChat instance in the sendMessageStream call, which will break conversation continuity, as well as an efficiency improvement regarding the Zod schema definition inside a loop.
32b4a85 to
eb75669
Compare
Replaces low-level direct calls to chat modules in `acpSession.ts` with `GeminiClient.sendMessageStream()`. This establishes parity with core terminal features—including chat compression, token masking safeguards, context validation limits, and execution tracing. - **Prompt Pipeline Refactoring**: Migrates `Session.prompt()` stream logic from calling `GeminiChat.sendMessageStream()` to `GeminiClient.sendMessageStream()`. - **Structured Events Mapping**: Converts underlying core state notifications (`GeminiEventType`) to line-delimited protocol interactions format. - **Enhanced Telemetry Tracking**: Introduces variable client identifiers distinguishing incoming requests sources (`tui`, `acp`, `cli-command`, or `a2a-server`). - **Automated Test Suites Extensions**: Appends core integration case parameters tests into `packages/cli/src/acp/acpSession.test.ts`.
eb75669 to
e68a560
Compare
Summary
Replaces low-level direct calls to chat modules in
acpSession.tswithGeminiClient.sendMessageStream(). This establishes parity with core terminal features—including chat compression, token masking safeguards, context validation limits, and execution tracing.Details
Session.prompt()stream logic from callingGeminiChat.sendMessageStream()toGeminiClient.sendMessageStream().GeminiEventType) to line-delimited protocol interactions format.tui,acp,cli-command, ora2a-server).packages/cli/src/acp/acpSession.test.ts.Before the change
Prior to this change, ACP interactive turn system bypassed the high-level client lifecycle manager (
GeminiClient) and orchestrated low-level calls directly via internalpackages/corecomponents.sequenceDiagram participant ACP Session participant Routing System participant GeminiChat ACP Session->>Routing System: router.route(RoutingContext) Routing System-->>ACP Session: Returns model target ACP Session->>GeminiChat: sendMessageStream(model, request parts) loop Stream Processing GeminiChat-->>ACP Session: yield Raw StreamEvent.CHUNK Note over ACP Session: - Manually parses usage data<br/>- Manually formats token info<br/>- Processes raw candidates content endPipeline Characteristics
GeminiChat.sendMessageStream().After/With this change
With this commit, the interactive turn orchestrator in
acpSession.tswas updated to use the high-level API provided byGeminiClient.sendMessageStream().sequenceDiagram participant ACP Session participant GeminiClient participant Core Orchestrator ACP Session->>GeminiClient: sendMessageStream(currentParts) opt Client Interceptors GeminiClient->>Core Orchestrator: Triggers Hooks & History Management end loop Engine Events GeminiClient-->>ACP Session: yield GeminiEventType (Content, Thought, ToolCall, Finished) Note over ACP Session: Maps clean protocol payloads<br/>to frontends (e.g., VS Code IDE) endPipeline Characteristics
GeminiClientpipeline.GeminiEventTyperather than low-level JSON-derived candidate chunks.clientNameset asacp,tui,cli-command, oracp-*IDE extensions)Summary Comparison
GeminiChat(Direct low-level interface)GeminiClient(Consolidated orchestrator)StreamEventType.CHUNKJSON objectsGeminiEventTypeabstractionsModelRouterServicetui,acp,cli-command)Related Issues
maintaince-gemini-cli#1604
How to Validate
Connect to ACP via Jetbrains and ensure all regular prompt workflows behave as expected.
Pre-Merge Checklist