Repository navigation
feat(acp): let clients steer a running turn with _session/steering - #29901
pulkitjain26 wants to merge 4 commits into
Conversation
|
📊 PR Size: size/L
|
Add the _geminicli.com/session/steer ACP extension method. A client that opts in (or a user with experimental.modelSteering on) can add a user message to a running session/prompt turn without cancelling it. Queued steering is wrapped with buildUserSteeringHintPrompt, as the terminal UI does for hints sent after tool calls, and added to the next model request in front of the tool results, or as one more request if the model was about to finish. Delivery is confirmed with a tagged user_message_chunk, and steering that never reaches the model is returned in the prompt response as undeliveredSteering. Fixes google-gemini#29900
bc68e8f to
83d735e
Compare
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 implements a new 'steering' feature for the Agent Client Protocol (ACP), enabling clients to provide real-time feedback or additional instructions to a model while a turn is already in progress. By avoiding the need to cancel and restart sessions, this change significantly improves the responsiveness and usability of ACP-integrated clients like IDE extensions. 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 the 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 counterproductive. 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 introduces support for steering a running turn in ACP mode, allowing clients (such as IDEs) to send real-time steering hints to an active session prompt without cancelling it. It adds the custom _geminicli.com/session/steer extension method, updates the session loop to deliver queued steering hints before tool results, handles undelivered steering, and updates the relevant documentation and tests. Feedback on the changes suggests using optional chaining when accessing injectionService to safely handle cases where it might be undefined, preventing potential runtime errors.
|
Hi there! Thank you for your interest in contributing to Gemini CLI. To ensure we maintain high code quality and focus on our prioritized roadmap, we only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. This PR will be closed in 7 days if it remains without that designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding. |
|
Live validation with a real model I ran the PR build (
The same scenarios also pass with a scripted fake model ( Side note, unrelated to this PR: the existing authenticate tests in |
Switch mid-turn steering from the Gemini-specific `_geminicli.com/session/steer` to the `_session/steering` extension that claude-agent-acp, codex-acp and Oh My Pi already implement, so clients can use one code path for all of these agents (as proposed in google-gemini#30048). - `initialize` advertises top-level `_meta.steering.supported`. No client opt-in or setting is needed; calling the method is the opt-in. - Requests take `{ sessionId, prompt, _meta?.steering?.idleBehavior }`. - A running turn answers `injected`, with Gemini CLI's `steerId` and `pending` count in `_meta["geminicli.com"]`. - With no turn running, the message starts a new turn (`startedNewTurn`), or is handed back as `promptRequired` when the client asks for it. - A turn that has started but not reached the model loop yet now accepts steering, so a steer there can't start a second turn. - Delivery points, delivered/undelivered updates and `undeliveredSteering` are unchanged. Fixes google-gemini#29900 Fixes google-gemini#30048
# Conflicts: # packages/cli/src/acp/acpSession.test.ts
|
This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding. |
Summary
Lets ACP clients (Zed, JetBrains, VS Code extensions, and others that run
gemini --acp) add a user message to a runningsession/promptturn without cancelling it, the same wayexperimental.modelSteeringworks in the terminal.Today an ACP client can only send
session/cancelor a new prompt, and both throw away the work in progress.This implements the
_session/steeringextension that Claude Code's ACP adapter (claude-agent-acp),codex-acpand Oh My Pi already ship, as proposed in #30048, so clients can use one code path for all of these agents. A client that doesn't call the method sees one extra_metakey in theinitializeresponse and nothing else.Details
Protocol (constants in
acpUtils.ts)initializeadvertises the extension at the top-level_meta.steering = { supported: true }, besideagentCapabilities. No client opt-in or setting is needed; calling the method is the opt-in._session/steeringwith{ sessionId, prompt: ContentBlock[], _meta?: { steering?: { idleBehavior?: "promptRequired" } } }. It answers with anoutcome:injected: a turn is running and the message was queued for it. Gemini CLI adds_meta["geminicli.com"] = { steerId, pending }.startedNewTurn: no turn was running, so the message started a new one. If the previous turn was still finishing, the new turn starts after it ends.promptRequiredwithreason: "noRunningTurn": no turn was running and the client asked for this instead of a new turn. Nothing is stored._meta["geminicli.com"]so they don't clash with the shared contract:user_message_chunkwith the user's text andsteering = { steerId, state: "delivered" }.session/promptresponse asundeliveredSteering. If the turn throws, each one is sent as auser_message_chunkwithstate: "undelivered"before the error.Behavior in
Session.prompt()session/promptarrives, including while the prompt is still being resolved, so a steer at that point can't start a second turn.buildUserSteeringHintPrompt, the same as the terminal UI does for hints sent after tool calls (useGeminiStream.ts). Each message still gets its owndeliveredupdate on the client./or$, text over 8,000 characters, and more than 20 queued messages are rejected with-32602. A secondsession/promptstill cancels the first, and the replaced turn reports its queue as undelivered.InjectionServicewith sourceuser_steering, so running local subagents see them, as in the terminal. This is a no-op unlessexperimental.modelSteeringis on.Dispatcher
GeminiAgent.extMethodvalidates and routes_session/steering(-32602for bad params or an unknown session) and returns-32601for unknown methods.GeminiAgent.extNotificationignores unknown notifications, as the ACP spec advises.No core changes. Terminal behavior and the
experimental.modelSteeringdefault are unchanged. No breaking changes.Open question for maintainers: the longer-term ACP proposal (agentclientprotocol/agent-client-protocol#1261) puts this on
session/promptitself in protocol v2. This PR follows the extension that agents ship today, and can move to the v2 form once it lands.Related Issues
Fixes #29900
Fixes #30048
How to Validate
Unit tests:
npm run build npm test -w @google/gemini-cli -- src/acp/For the full suite, run
GEMINI_CLI_TRUST_WORKSPACE=true npm run preflight, as CI does. Without that variable, 9 tests ingemini.test.tsxfail onmaintoo.New cases in
acpSession.test.tscover delivery, ordering, continuation when the model ends,startedNewTurn,promptRequired, cancel, open permission requests, turn limits, replacement prompts, errors, validation, injection, and history replay.acpRpcDispatcher.test.tscovers the capability, routing and parameter validation.Protocol smoke test against the built CLI (no model call needed): send
initializeand check_meta.steering.supported; steer an unknown session and expect-32602; call an unknown_method and expect-32601.End to end with an ACP client: start a prompt that runs a tool, send
_session/steeringwhile it runs, then check that the result isinjected, the next model request contains the hint, the client gets adeliveredchunk, and the turn finishes without being cancelled.I ran 14 scenarios like this over stdio against the built CLI and a real model (Code Assist), covering each outcome, cancel, replacement prompts, open permission requests, turn limits, validation, the setting turned off, and session replay. All passed. A released CLI (0.67.0) answers
-32601and advertises nothing, so clients can detect support.Pre-Merge Checklist