Respect blocking PostToolUse hooks in code mode#28365
Merged
Merged
Conversation
abhinav-oai
commented
Jun 15, 2026
| pub stop_reason: Option<String>, | ||
| pub should_block: bool, | ||
| pub additional_contexts: Vec<String>, | ||
| pub feedback_message: Option<String>, |
Collaborator
Author
There was a problem hiding this comment.
feedback_message remains the single message channel for both direct and code mode
should_block only determines whether code mode rejects with that message
abhinav-oai
commented
Jun 15, 2026
| let code_mode_post_tool_use_error = | ||
| if matches!(&invocation.source, ToolCallSource::CodeMode { .. }) { | ||
| post_tool_use_outcome.as_ref().and_then(|outcome| { | ||
| outcome.should_block.then(|| { |
Collaborator
Author
There was a problem hiding this comment.
continue:false remains feedback-only in code mode just like in direct mode
Only explicit PostToolUse blocking signals (decision:block or exit code 2) set should_block and reject the promise
pakrym-oai
reviewed
Jun 15, 2026
| } | ||
|
|
||
| #[derive(Clone, Copy)] | ||
| enum CodeModePostToolUseBlockMode { |
pakrym-oai
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make blocking hook behavior reliable for tools invoked from code mode.
Previously, a
PostToolUsehook could block a completed tool result, but code mode would still return the original typed result to JavaScript. The hook appeared blocked in hook telemetry while the running script continued with the result.This change:
PostToolUseblocksdecision: "block"and exit code 2 to the same blocking behaviorHook semantics in code mode
updatedInputdecision: "block"decision: "block"continue: falseTest coverage
Added or strengthened end-to-end coverage proving that:
decision: "block"rejects after the command executescontinue: falsewithout a reason produces deterministic fallback feedback