Skip to content

Commit 13a44cf

Browse files
feat(cli): add ACP host input requests
1 parent 7311e24 commit 13a44cf

File tree

7 files changed

+1073
-53
lines changed

7 files changed

+1073
-53
lines changed

docs/cli/acp-mode.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,58 @@ and Gemini CLI (the server).
5252
The core of the ACP implementation can be found in
5353
`packages/cli/src/acp/acpClient.ts`.
5454

55+
## Host input extensions
56+
57+
ACP covers prompts, cancellations, permissions, and session control. Gemini CLI
58+
also exposes a Gemini-specific ACP extension for structured host input so an ACP
59+
client can surface questions in its own UI instead of handing control back to
60+
the terminal.
61+
62+
During `initialize`, Gemini CLI advertises the extension in
63+
`agentCapabilities._meta.geminiCli.hostInput`:
64+
65+
```json
66+
{
67+
"version": 1,
68+
"requestUserInput": true,
69+
"method": "gemini/requestUserInput",
70+
"supportedKinds": ["ask_user", "exit_plan_mode"]
71+
}
72+
```
73+
74+
To enable host input, the ACP client must advertise
75+
`clientCapabilities._meta.geminiCli.hostInput` with `requestUserInput: true`.
76+
The client can also narrow support by setting `supportedKinds`.
77+
78+
- Include `ask_user` to let Gemini CLI surface `ask_user` tool requests over
79+
ACP.
80+
- Include `exit_plan_mode` to let Gemini CLI surface plan-approval questions
81+
over ACP.
82+
- Omit `ask_user` if you want to keep `ask_user` disabled in ACP mode while
83+
still supporting other host-input request kinds.
84+
85+
If the client doesn't opt in, Gemini CLI keeps `ask_user` excluded in ACP mode.
86+
This preserves the default ACP behavior and avoids opening host-driven dialogs
87+
unless the client has explicitly implemented them.
88+
89+
When Gemini CLI needs host input, it calls `gemini/requestUserInput` as an ACP
90+
extension request. The request includes:
91+
92+
- `sessionId` for the active ACP session
93+
- `requestId` for the host-input interaction
94+
- `kind`, such as `ask_user` or `exit_plan_mode`
95+
- `title` and `questions`
96+
- optional `extraParts`
97+
- optional `toolCall` metadata
98+
99+
The client responds with either:
100+
101+
- `{"outcome":"submitted","answers":{"0":"..."}}`
102+
- `{"outcome":"cancelled"}`
103+
104+
This extension is separate from MCP. Use it when you want Gemini CLI to keep
105+
owning the tool flow while your ACP host owns the user-facing input surface.
106+
55107
### Extending with MCP
56108

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

80132
- `initialize`: Establishes the initial connection and lets the client to
81-
register its MCP server.
133+
register its MCP server and negotiate Gemini-specific ACP extensions.
82134
- `authenticate`: Authenticates the user.
83135
- `newSession`: Starts a new chat session.
84136
- `loadSession`: Loads a previous session.

docs/tools/ask-user.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,81 @@ confirmation.
3333
- Presents an interactive dialog to the user with the specified questions.
3434
- Pauses execution until the user provides answers or dismisses the dialog.
3535
- Returns the user's answers to the model.
36+
- In ACP mode, Gemini CLI keeps `ask_user` disabled unless the ACP client
37+
explicitly opts in to Gemini CLI host-input requests.
3638

3739
- **Output (`llmContent`):** A JSON string containing the user's answers,
3840
indexed by question position (e.g.,
3941
`{"answers":{"0": "Option A", "1": "Some text"}}`).
4042

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

45+
## ACP mode
46+
47+
In ACP mode, Gemini CLI doesn't assume that the host client can handle
48+
interactive user questions. To preserve existing ACP behavior, Gemini CLI
49+
excludes `ask_user` unless the host explicitly advertises support.
50+
51+
To enable `ask_user` over ACP, the host client must do all of the following:
52+
53+
1. Set `clientCapabilities._meta.geminiCli.hostInput.requestUserInput` to
54+
`true`.
55+
2. Include `ask_user` in
56+
`clientCapabilities._meta.geminiCli.hostInput.supportedKinds`, or omit
57+
`supportedKinds` entirely.
58+
3. Handle the `gemini/requestUserInput` ACP extension request and return either
59+
submitted answers or cancellation.
60+
61+
If the host omits `ask_user` from `supportedKinds`, Gemini CLI keeps the tool
62+
disabled in ACP mode. This lets a client support other host-input request kinds
63+
without taking on `ask_user`.
64+
65+
When enabled, Gemini CLI sends the same question payload that the terminal UI
66+
uses. The ACP extension request looks like this:
67+
68+
```json
69+
{
70+
"sessionId": "session-123",
71+
"requestId": "ask_user-456",
72+
"kind": "ask_user",
73+
"title": "Ask User",
74+
"questions": [
75+
{
76+
"header": "Database",
77+
"question": "Which database would you like to use?",
78+
"type": "choice",
79+
"options": [
80+
{
81+
"label": "PostgreSQL",
82+
"description": "Powerful, open source object-relational database system."
83+
},
84+
{
85+
"label": "SQLite",
86+
"description": "C-library that implements a SQL database engine."
87+
}
88+
]
89+
}
90+
]
91+
}
92+
```
93+
94+
The ACP client responds with one of these payloads:
95+
96+
```json
97+
{
98+
"outcome": "submitted",
99+
"answers": {
100+
"0": "PostgreSQL"
101+
}
102+
}
103+
```
104+
105+
```json
106+
{
107+
"outcome": "cancelled"
108+
}
109+
```
110+
43111
## Usage Examples
44112

45113
### Multiple Choice Question

0 commit comments

Comments
 (0)