Skip to content

feat(acp): let clients steer a running turn with _session/steering - #29901

Closed
pulkitjain26 wants to merge 4 commits into
google-gemini:mainfrom
pulkitjain26:feat/acp-steering
Closed

pulkitjain26 wants to merge 4 commits into
google-gemini:mainfrom
pulkitjain26:feat/acp-steering

Conversation

@pulkitjain26

@pulkitjain26 pulkitjain26 commented Oct 23, 2026 •

Copy link
Copy Markdown

Summary

Lets ACP clients (Zed, JetBrains, VS Code extensions, and others that run gemini --acp) add a user message to a running session/prompt turn without cancelling it, the same way experimental.modelSteering works in the terminal.
Today an ACP client can only send session/cancel or a new prompt, and both throw away the work in progress.

This implements the _session/steering extension that Claude Code's ACP adapter (claude-agent-acp), codex-acp and 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 _meta key in the initialize response and nothing else.

Details

Protocol (constants in acpUtils.ts)

  • initialize advertises the extension at the top-level _meta.steering = { supported: true }, beside agentCapabilities. No client opt-in or setting is needed; calling the method is the opt-in.
  • New request _session/steering with { sessionId, prompt: ContentBlock[], _meta?: { steering?: { idleBehavior?: "promptRequired" } } }. It answers with an outcome:
    • 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.
    • promptRequired with reason: "noRunningTurn": no turn was running and the client asked for this instead of a new turn. Nothing is stored.
  • Additive Gemini CLI fields, under _meta["geminicli.com"] so they don't clash with the shared contract:
    • When a message reaches the model, the client gets a user_message_chunk with the user's text and steering = { steerId, state: "delivered" }.
    • Messages still queued when the turn ends (cancel, replacement prompt, or turn limit) come back in the session/prompt response as undeliveredSteering. If the turn throws, each one is sent as a user_message_chunk with state: "undelivered" before the error.

Behavior in Session.prompt()

  • A turn accepts steering from the moment session/prompt arrives, including while the prompt is still being resolved, so a steer at that point can't start a second turn.
  • Queued messages are added at the start of each loop iteration, after the turn-limit and cancel checks, in front of the tool results.
  • They're joined and wrapped with buildUserSteeringHintPrompt, the same as the terminal UI does for hints sent after tool calls (useGeminiStream.ts). Each message still gets its own delivered update on the client.
  • If the model finishes without tool calls while a message is queued, the loop sends one more request in the same turn, like the terminal UI auto-submits leftover hints.
  • Running tools and open permission requests are not interrupted. While a turn runs, text starting with / or $, text over 8,000 characters, and more than 20 queued messages are rejected with -32602. A second session/prompt still cancels the first, and the replaced turn reports its queue as undelivered.
  • Messages are also passed to InjectionService with source user_steering, so running local subagents see them, as in the terminal. This is a no-op unless experimental.modelSteering is on.
  • Loading a session replays stored steering as the user's own text, not the wrapped prompt.

Dispatcher

  • GeminiAgent.extMethod validates and routes _session/steering (-32602 for bad params or an unknown session) and returns -32601 for unknown methods. GeminiAgent.extNotification ignores unknown notifications, as the ACP spec advises.

No core changes. Terminal behavior and the experimental.modelSteering default are unchanged. No breaking changes.

Open question for maintainers: the longer-term ACP proposal (agentclientprotocol/agent-client-protocol#1261) puts this on session/prompt itself 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

  1. 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 in gemini.test.tsx fail on main too.

    New cases in acpSession.test.ts cover 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.ts covers the capability, routing and parameter validation.

  2. Protocol smoke test against the built CLI (no model call needed): send initialize and check _meta.steering.supported; steer an unknown session and expect -32602; call an unknown _ method and expect -32601.

  3. End to end with an ACP client: start a prompt that runs a tool, send _session/steering while it runs, then check that the result is injected, the next model request contains the hint, the client gets a delivered chunk, 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 -32601 and advertises nothing, so clients can detect support.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@github-actions github-actions Bot added the size/l A large sized PR label Oct 23, 2026
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

📊 PR Size: size/L

  • Lines changed: 934
  • Additions: +930
  • Deletions: -4
  • Files changed: 8

@gemini-cli gemini-cli Bot added the area/non-interactive Issues related to GitHub Actions, SDK, 3P Integrations, Shell Scripting, Command line automation label Oct 23, 2026
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
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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

  • ACP Protocol Extension: Introduced a new protocol extension _geminicli.com/session/steer that allows clients to inject user messages into a running session turn without cancelling it.
  • Steering Logic: Implemented queueing and delivery logic in Session.prompt to handle steering hints, ensuring they are processed at the start of model loops or as follow-up requests.
  • Capability Advertisement: Added support for advertising steering capabilities during the initialize handshake, with opt-in support via client capabilities or configuration settings.
  • Error Handling and Reporting: Added mechanisms to report undelivered steering messages back to the client if a turn is cancelled, replaced, or fails.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/cli/src/acp/acpSession.ts Resolved
@gemini-cli

gemini-cli Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

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.

@pulkitjain26

Copy link
Copy Markdown
Author

Live validation with a real model

I ran the PR build (83d735ef5) in ACP mode on macOS (Node 24.21) against a real Gemini model (Code Assist login). The client was a small script that drives gemini --acp over stdio with the ACP TypeScript SDK. All 15 scenarios passed:

  • Delivery: a steer sent while sleep 8 ran came back queued. It was delivered (user_message_chunk with its steerId) after the tool finished, and the model acted on it in the same turn (end_turn, no cancel). A steer sent while the model wrote a long final answer, with no tools, got one more request in the same turn. Two steers were delivered together, in order.
  • Permission prompt open: the steer was accepted, the prompt stayed open, and the message was delivered after approval.
  • Nothing lost: session/cancel, a replacing session/prompt and maxSessionTurns: 1 each returned the queued message in _meta["geminicli.com"].undeliveredSteering. A steer after the turn ended got no_active_turn.
  • Validation and gating: /cmd, $skill, blank or over-long text, a 21st pending message, an unknown session and a non-text block each gave -32602. Without the opt-in or the setting the result was -32000, and an unknown extension method gave -32601. Enabling through experimental.modelSteering alone also works.
  • Replay: session/load replays the steering as the user's own words, not the internal User hints: prompt.
  • Fallback: against 0.65.0 there is no capability in initialize and the steer call gets -32601, so clients can detect older versions.

The same scenarios also pass with a scripted fake model (--fake-responses), and the unit tests in src/acp/ pass (136).

Side note, unrelated to this PR: the existing authenticate tests in acpRpcDispatcher.test.ts call the real clearCachedCredentialFile(), so running them deletes the developer's ~/.gemini/oauth_creds.json. Happy to open a separate issue for it.

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
@pulkitjain26 pulkitjain26 changed the title feat(acp): let clients steer a running turn feat(acp): let clients steer a running turn with _session/steering Nov 5, 2026
# Conflicts:
#	packages/cli/src/acp/acpSession.test.ts
@gemini-cli

gemini-cli Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/non-interactive Issues related to GitHub Actions, SDK, 3P Integrations, Shell Scripting, Command line automation size/l A large sized PR status/pr-nudge-sent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support steering a running turn over ACP (_session/steering) ACP: let clients steer a running turn (mid-turn user hints)

1 participant