Skip to content
54 changes: 53 additions & 1 deletion docs/cli/acp-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,58 @@ and Gemini CLI (the server).
The core of the ACP implementation can be found in
`packages/cli/src/acp/acpClient.ts`.

## Host input extensions

ACP covers prompts, cancellations, permissions, and session control. Gemini CLI
also exposes a Gemini-specific ACP extension for structured host input so an ACP
client can surface questions in its own UI instead of handing control back to
the terminal.

During `initialize`, Gemini CLI advertises the extension in
`agentCapabilities._meta.geminiCli.hostInput`:

```json
{
"version": 1,
"requestUserInput": true,
"method": "gemini/requestUserInput",
"supportedKinds": ["ask_user", "exit_plan_mode"]
}
```

To enable host input, the ACP client must advertise
`clientCapabilities._meta.geminiCli.hostInput` with `requestUserInput: true`.
The client can also narrow support by setting `supportedKinds`.

- Include `ask_user` to let Gemini CLI surface `ask_user` tool requests over
ACP.
- Include `exit_plan_mode` to let Gemini CLI surface plan-approval questions
over ACP.
- Omit `ask_user` if you want to keep `ask_user` disabled in ACP mode while
still supporting other host-input request kinds.

If the client doesn't opt in, Gemini CLI keeps `ask_user` excluded in ACP mode.
This preserves the default ACP behavior and avoids opening host-driven dialogs
unless the client has explicitly implemented them.

When Gemini CLI needs host input, it calls `gemini/requestUserInput` as an ACP
extension request. The request includes:

- `sessionId` for the active ACP session
- `requestId` for the host-input interaction
- `kind`, such as `ask_user` or `exit_plan_mode`
- `title` and `questions`
- optional `extraParts`
- optional `toolCall` metadata

The client responds with either:

- `{"outcome":"submitted","answers":{"0":"..."}}`
- `{"outcome":"cancelled"}`

This extension is separate from MCP. Use it when you want Gemini CLI to keep
owning the tool flow while your ACP host owns the user-facing input surface.

### Extending with MCP

ACP can be used with the Model Context Protocol (MCP). This lets an ACP client
Expand All @@ -78,7 +130,7 @@ to control Gemini CLI.
### Core methods

- `initialize`: Establishes the initial connection and lets the client to
register its MCP server.
register its MCP server and negotiate Gemini-specific ACP extensions.
- `authenticate`: Authenticates the user.
- `newSession`: Starts a new chat session.
- `loadSession`: Loads a previous session.
Expand Down
68 changes: 68 additions & 0 deletions docs/tools/ask-user.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,81 @@ confirmation.
- Presents an interactive dialog to the user with the specified questions.
- Pauses execution until the user provides answers or dismisses the dialog.
- Returns the user's answers to the model.
- In ACP mode, Gemini CLI keeps `ask_user` disabled unless the ACP client
explicitly opts in to Gemini CLI host-input requests.

- **Output (`llmContent`):** A JSON string containing the user's answers,
indexed by question position (for example,
`{"answers":{"0": "Option A", "1": "Some text"}}`).

- **Confirmation:** Yes. The tool inherently involves user interaction.

## ACP mode

In ACP mode, Gemini CLI doesn't assume that the host client can handle
interactive user questions. To preserve existing ACP behavior, Gemini CLI
excludes `ask_user` unless the host explicitly advertises support.

To enable `ask_user` over ACP, the host client must do all of the following:

1. Set `clientCapabilities._meta.geminiCli.hostInput.requestUserInput` to
`true`.
2. Include `ask_user` in
`clientCapabilities._meta.geminiCli.hostInput.supportedKinds`, or omit
`supportedKinds` entirely.
3. Handle the `gemini/requestUserInput` ACP extension request and return either
submitted answers or cancellation.

If the host omits `ask_user` from `supportedKinds`, Gemini CLI keeps the tool
disabled in ACP mode. This lets a client support other host-input request kinds
without taking on `ask_user`.

When enabled, Gemini CLI sends the same question payload that the terminal UI
uses. The ACP extension request looks like this:

```json
{
"sessionId": "session-123",
"requestId": "ask_user-456",
"kind": "ask_user",
"title": "Ask User",
"questions": [
{
"header": "Database",
"question": "Which database would you like to use?",
"type": "choice",
"options": [
{
"label": "PostgreSQL",
"description": "Powerful, open source object-relational database system."
},
{
"label": "SQLite",
"description": "C-library that implements a SQL database engine."
}
]
}
]
}
```

The ACP client responds with one of these payloads:

```json
{
"outcome": "submitted",
"answers": {
"0": "PostgreSQL"
}
}
```

```json
{
"outcome": "cancelled"
}
```

## Usage Examples

### Multiple Choice Question
Expand Down
Loading