You wired an editor client into Gemini CLI over ACP, wrote a BeforeAgent hook that blocks prompts containing a forbidden word, sent the blocked prompt, and the client received stopReason: "end_turn" with zero tokens and no session/update at all. No error, no reason. To the client, it was a turn that ended without doing anything. In 0.68.0, the latest on npm as of 2026-11-16, this happens because the event carrying the denial is never translated into the ACP protocol.
What does an ACP client receive when a hook denies a prompt?
A successful response, empty. This is the literal return of session/prompt after a BeforeAgent hook exits with 2:
{ "stopReason": "end_turn", "usage": { "inputTokens": 0, "outputTokens": 0, "totalTokens": 0 } }
The report in issue google-gemini/gemini-cli #30114, opened on 2026-11-03, shows the comparison: the same prompt without the blocked word comes back with hello, end_turn and around 10,000 input tokens. With the blocked word, the prompt simply vanishes.
It is the worst failure shape for anyone writing a client: the turn does not fail, so your error handling never fires, and the UI sits waiting for text that will never arrive.
Why does a denied prompt become an empty turn?
Because the event exists and is emitted, but the ACP switch has no case for it. GeminiClient detects the denial in packages/core/src/core/client.ts and returns its own event:
if (hookOutput?.isBlockingDecision()) {
return {
type: GeminiEventType.AgentExecutionBlocked,
value: {
reason: hookOutput.getEffectiveReason(),
systemMessage: hookOutput.systemMessage,
},
};
}
On the other side, in packages/cli/src/acp/acpSession.ts, the method that translates the stream into the ACP protocol has cases for Content, Thought, Retry, ToolCallRequest, Finished, ModelInfo, MaxSessionTurns, LoopDetected, ContextWindowWillOverflow and Error. It ends with default: break;. AgentExecutionBlocked falls into that default.
Since stopReason starts as 'end_turn' and nothing changes it, the function returns success. The reason the hook computed exists in memory but never becomes an agent_message_chunk or a distinct stop reason.
| Stream event | What ACP does with it |
|---|---|
Content | sends agent_message_chunk |
Thought | sends agent_thought_chunk |
ToolCallRequest | requests permission and runs the tool |
Finished | sets the turn stop reason |
MaxSessionTurns and LoopDetected | stopReason: max_turn_requests |
ContextWindowWillOverflow | stopReason: max_tokens |
Error | throws RequestError with the status |
AgentExecutionBlocked | nothing, falls into default |
AgentExecutionStopped | nothing, falls into default |
How do you confirm this in thirty seconds?
Look for the event in the ACP file. If it is missing, you are on the bug:
grep -c AgentExecutionBlocked packages/cli/src/acp/acpSession.ts
# 0
Zero is the expected result in 0.68.0 and also on main as of 2026-11-16. Check your hook config too: the block only happens with decision: "deny", with continue: false or with exit 2. A hook that just prints a warning and exits 0 blocks nothing and never reaches this case.
{
"hooks": {
"BeforeAgent": [
{
"hooks": [
{
"type": "command",
"name": "deny-prompt",
"command": "grep -q deny-this-word && { echo 'denied by policy' >&2; exit 2; }; exit 0"
}
]
}
]
}
}
Where does the reason show up, if ACP drops it?
In non-interactive mode. There the same event has explicit handling, in packages/cli/src/nonInteractiveCli.ts, and the message goes to stderr with a [WARNING] prefix:
gemini -p "Reply with the single word hello. deny-this-word"
# [WARNING] Agent execution blocked: denied by policy
That is the fastest test to separate two different problems: if -p shows the block, your hook is right and what is missing is the ACP passthrough. If -p answers normally, the hook never fired.
Why does the log say the hook failed?
Because exiting with code 2 is counted as a process failure. In packages/core/src/hooks/hookRunner.ts, the hook result gets success: exitCode === EXIT_CODE_SUCCESS. Exiting with 2 to block is the path documented as an emergency brake, but it is recorded as an unsuccessful run, and then the CLI emits the warning:
Hook(s) [deny-prompt] failed for event BeforeAgent. Press F12 to see the debug drawer for more details.
A deliberate denial and a broken hook look identical. If you want the denial to count as a success, use the structured format: print {"decision": "deny", "reason": "..."} to stdout and exit with 0. The block still happens, the reason is the same, and the hook stops showing up as failed.
echo '{"decision": "deny", "reason": "Security Policy: potential secret detected."}'
exit 0
How do you fix the empty turn in ACP?
Two exits, and they combine. The first is in the client, which is what you control today without waiting for upstream: treat stopReason: "end_turn" with totalTokens: 0 and no session/update as a blocked prompt, and show your own message instead of an empty bubble.
The second is in the agent. Add the case to the switch in acpSession.ts, right before default, so the reason reaches the wire:
case GeminiEventType.AgentExecutionBlocked:
await this.sendUpdate({
sessionUpdate: 'agent_message_chunk',
content: {
type: 'text',
text: `Agent execution blocked: ${
event.value.systemMessage?.trim() || event.value.reason
}`,
},
});
break;
The text is the same one non-interactive mode already prints, so the message stays consistent across both paths. After applying it, rebuild with npm run build and run gemini --acp again: the client now receives a text chunk before end_turn, and the UI has something to show.
If you depend on the published package, do not edit node_modules. Patch your fork, or use the client-side path until issue #30114 is closed.
Is there a published fix yet?
No, as of 2026-11-16. We checked the file in three places: the v0.68.0 tag, the latest package on npm, and main. None of them has a case for AgentExecutionBlocked in acpSession.ts. Issue #30114 is still open, and neighboring reports show the same hole: #30199 shows that continue: false ends the turn with no message, and #30129 shows that SessionStart and Notification hooks never run under ACP.
Meanwhile, testing with gemini -p remains the most reliable way to know whether your hook works, regardless of whether the client is receiving the reason.
If you want a coding agent in the terminal without counting tokens on every attempt, Verboo Code offers unlimited tokens.



