[BUG] prompt.suggest hooks never run for the engine's own suggestion in SDK mode (Claude Desktop Code tab)
Environment
- Claude Code 2.1.286, the CLI that Claude Desktop 2.19675.0 runs for the Code tab
- Windows 11 Pro 10.0.26200
CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1
Summary
A function-hooks plugin that registers on('prompt.suggest', ...) never sees Claude Code's own after-turn suggestion when the session runs in SDK mode (stream-json in and out), which is how the Claude Desktop Code tab runs it. The suggestion reaches the host unchanged as a prompt_suggestion message. The hooks module is loaded, but the hook is never invoked. Rewriting the text with next({ ...e, text }) or hiding it with { isShown: false } has no effect in Desktop.
The prompt.suggest docs in the typings describe the event as covering "the engine's guess after a turn". The { kind: 'suggestion' } origin is documented the same way. Nothing in the docs limits either one to the terminal.
Repro
- Plugin (also at https://github.com/Vatroslav/cc-mod-suggestion-sentence-case/tree/main/repro/sdk-prompt-suggest):
``ts[prompt.suggest ran] ${e.text}
export const register: Register = on => {
on('prompt.suggest', ($, e, next) => next({ ...e, text: }))``
}
- Run in SDK mode:
````
CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude -p --input-format stream-json --output-format stream-json --verbose --prompt-suggestions --plugin-dir ./sdk-prompt-suggest --debug
- Send two user messages, waiting for each
result:
- "In English please. I want to learn about Python list comprehensions. Just say OK for now."
- "Explain list comprehensions in one sentence, then ask me whether I want a code example."
Expected: {"type":"prompt_suggestion","suggestion":"[prompt.suggest ran] yes", ...}
Actual: {"type":"prompt_suggestion","suggestion":"yes", ...} (measured 2026-10-06).
The debug log shows hooks module repro-sdk-prompt-suggest@inline loaded (...); events: prompt.suggest. It also shows the forked [prompt_suggestion] agent finishing. It has no prompt.suggest (suggestion): N chars, shown|not shown line, which the chain writes whenever it runs.
The same happens in the Desktop Code tab with a real plugin: https://github.com/Vatroslav/cc-mod-suggestion-sentence-case capitalizes suggestions and adds a full stop. It never changes a suggestion in Desktop, although the plugin is loaded in every session.
Likely cause
From reading the minified 2.1.286 bundle, so the identifiers are specific to this build:
- Terminal path: the post-turn suggestion function (
Rso) returns early unlessquerySourcestarts withrepl_main_thread. It then runs the text through theprompt.suggestchain (_vo, origin{ kind: 'suggestion' }), and core places it in the composer. - SDK path: the SDK suggestion class (
Gh, built byJhwithgenerate: (s, g) => Alr(s, e, r, g, "sdk")) emits{ type: "prompt_suggestion", suggestion: v.suggestion }fromafterResultstraight throughthis.emit. It never calls the chain. - The
plugin_ownsgate (Gnt()) is hard-coded tofalse.
Suggested fix
In the SDK path, run the generated text through the same prompt.suggest chain, with emitting the prompt_suggestion message as the core step. Emit the rewritten text, and emit nothing when a hook answers { isShown: false }.
If the event is meant to be terminal-only, say so in the prompt.suggest docs and in the plugin-authoring skill.
Impact
Any plugin that rewrites or hides prompt suggestions does nothing in the Claude Desktop Code tab or in any other SDK host.
Related, but different
#79919 and #88391 are about suggestions not appearing at all. Here they appear, but bypass the hook.