fix(headless): honor can_use_tool deny interrupts - #3592
Open
GautamSharma99 wants to merge 1 commit into
Open
Conversation
GautamSharma99
requested review from
4shub,
carenthomas,
cpacker,
devanshrj,
jnjpng,
kl2806 and
sarahwooders
as code owners
July 31, 2026 09:57
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Fixes #3582.
Bidirectional headless clients can already send
interrupt: truewith a deniedcan_use_toolresponse, but the runtime previously discarded that field and continued the approval flow. This change carries the interrupt intent into the active turn lifecycle and terminates the turn through its existingAbortController.What changed
headless-permissionowner module.interrupt: true.interruptvalues as ordinary denials.descriptionargument so the end-to-end approval path is exercised rather than auto-denied during validation.src/headless.tsby 51 lines and lowered its source-size baseline from 5,243 to 5,192.Lifecycle and ordering
For an interrupting denial, the runtime does not synthesize or emit a denied tool return. It aborts the current controller and exits the approval loop immediately. The turn emits one terminal
resultwith subtypeinterrupted, and no tool execution or provider continuation occurs for that response. If the backend still has a dangling approval, the existing post-interrupt recovery path resolves it before the next user turn.This ordering prevents an auto-approved sibling decision in the same approval batch from executing after the client requested a stop.
Tests
Added focused coverage for:
interrupt, which retains the current continuation behavior;interrupt: true, including abort-before-return ordering;Validation completed:
bun test src/headless-permission.test.ts src/headless-interrupt-latch.test.ts src/backend/fake-headless-backend.test.ts— 16 passed, 0 failedbun run check— all 12 checks passed