mirror of
https://github.com/agentclientprotocol/claude-agent-acp.git
synced 2026-11-23 01:31:16 +00:00
A client that advertises `session.promptSuggestions` now gets the prompt
that Claude Code predicts the user sends next, as ACP's unstable
`prompt_suggestions_update`, on v1 and v2.
## Why
Claude Code predicts the next prompt after a turn. The adapter sent that
prediction only to JetBrains AIR, as
`session_info_update._meta.promptSuggestions`, because ACP had no update
for it. ACP now has one, behind the client capability
`session.promptSuggestions` in both versions.
## What a client sees
- **With the capability:** `prompt_suggestions_update` with one
suggestion, whose prompt is one text block. An empty list withdraws it.
- **JetBrains AIR:** the `_meta` form, unchanged. An AIR client that
also advertises the capability gets both, the standard update first.
- **Neither:** nothing, and the session asks Claude Code for no
prediction. On v2 that was so before. On v1 it is new: see "v1 cost"
below.
The standard form follows the rules of the draft pages ("Prompt
suggestions (unstable)"):
- The list is withdrawn when a prompt is accepted, and at a
`conversation_reset`.
- A suggestion that is empty or only whitespace is not sent.
- A prediction that arrives while Claude works is dropped, for example
when another prompt was queued before the result. ACP requires a
prediction to match the conversation when it is sent.
- On v2, the list is withdrawn when foreground work starts without a
prompt, such as a cycle that Claude Code starts after a background task.
- Nothing is replayed. Predictions are not in the transcript.
## How
`PromptSuggestions` in `src/prompt-suggestions.ts`, which both cores
share, keeps one state per form and returns the updates to send. The
`_meta` form keeps the rules it had. The v1 core changes only its
existing call sites, and `src/v2/session-update.ts` passes the new
update through.
`promptSuggestionOptions` in the same module gives both cores the SDK
option, by the rule that `PromptSuggestions.forClient` uses: on for a
client that takes a form of the prediction, absent for any other.
## For the reviewer
- **v1 cost:** on `main`, the SDK option `promptSuggestions: true` is on
for every v1 client, not only AIR, so Claude Code spends a request per
turn on a prediction that a client other than AIR never gets. This PR
turns the option on only for AIR and for a client that advertises the
capability, as v2 does. A v1 client that is neither stops paying for the
prediction and sees no other change: it got nothing of it before. A
client's own `_meta.claudeCode.options.promptSuggestions` still wins, in
both directions.
- **v1 autonomous cycles:** the withdrawal when work starts without a
prompt is v2 only. On v1, a prediction that arrives during such a cycle
is dropped, but a list already shown stays until the next prompt.
- **A session that stays live through a load or resume** keeps its
state, while the client's list is empty by rule. The next clear can send
a redundant empty list, and an identical prediction is not sent again.
## Checked against the real CLI
A client that advertises the capability got one
`prompt_suggestions_update` after the second turn of a session, on v1
and on v2. Claude Code predicts nothing after a session's first turn. I
did not check the queued-prompt case live.
## Tests
- `prompt-suggestions.test.ts` (v1) and `v2.test.ts`: each form alone
and both together, the withdrawal at a prompt, the dropped prediction
while Claude works, and on v2 the withdrawal when work starts without a
prompt.
- `create-session-options.test.ts` (v1): the SDK option is on for AIR
and for a client with the capability, absent for any other client, and
off when the caller passes `false`.
`npm run build`, `npm run check` and `npm run test:run` pass (4364
tests, with `main` merged in). The live check above was made before the
v1 option was gated. I did not repeat it.