feat(core): introduce AgentSession and rename stream events to agent events#23159
feat(core): introduce AgentSession and rename stream events to agent events#23159adamfweidman merged 6 commits intomainfrom
Conversation
|
Hi @mbleigh, 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 significantly enhances the agent event handling mechanism by introducing a new 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
|
There was a problem hiding this comment.
Code Review
This pull request is a significant and well-executed refactoring of the agent communication protocol. The transition from a stateful stream() method to a subscription-based AgentProtocol is a solid architectural improvement, and the new AgentSession provides a convenient AsyncIterable wrapper for consumers. The code is well-structured, and the tests have been thoroughly updated to reflect the changes. I have one suggestion regarding a potential performance issue in the event queue processing logic, which could be important for streams with a high volume of events.
|
Size Change: -4 B (0%) Total Size: 26.3 MB
ℹ️ View Unchanged
|
Summary
This PR updates the
AgentProtocolinterface to use a subscription-based model and introducesAgentSession, a wrapper that provides anAsyncIterableAPI (sendStream) for consuming agent events. It also renamesstream_startandstream_endevents toagent_startandagent_endto better reflect their role in indicating agent activity.Details
AgentProtocolto replace thestream()method with asubscribe()method.AgentSessioninpackages/core/src/agent/agent-session.tsto provide a higher-levelAsyncIterableinterface.MockAgentProtocolto support the new interface and ensure correct event ordering (e.g.,streamIdis returned beforeagent_startis emitted).StreamStart->AgentStart,StreamEnd->AgentEnd.AgentSession.Related Issues
Related to #20995
How to Validate
npm test -w @google/gemini-cli-coreto verify agent and session tests.npm run preflightto ensure no regressions across the monorepo.Pre-Merge Checklist