Skip to content

fix(hooks): question-preference-hook breaks AskUserQuestion in non-interactive sessions (explicit permissionDecision 'defer') - #2165

Closed
dpnascimento wants to merge 1 commit into
garrytan:mainfrom
dpnascimento:fix/auq-hook-no-explicit-defer
Closed

dpnascimento wants to merge 1 commit into
garrytan:mainfrom
dpnascimento:fix/auq-hook-no-explicit-defer

Conversation

@dpnascimento

Copy link
Copy Markdown

Problem

After running gstack setup, AskUserQuestion stops working entirely in non-interactive Claude Code sessions (e.g. the desktop app): the question UI never renders.

Root cause: the question-preference-hook PreToolUse hook emits permissionDecision: 'defer' as its "no opinion" outcome. But defer is a real value in Claude Code with a specific meaning — "pause this tool call and hand control back" — and it is honored in print/non-interactive mode. Claude Code's own strings confirm the split:

  • interactive: returned permissionDecision=defer in interactive mode; ignoring (defer is print-mode only)
  • non-interactive: the tool call is actually deferred (tengu_pre_tool_hook_deferred / hook_deferred_tool)

So in any non-interactive session, every AUQ call the hook doesn't auto-decide gets swallowed. Reproduced on Claude Code 2.1.187 (desktop app).

Fix

The neutral outcome for a PreToolUse hook is a silent exit 0. defer() now:

  • emits nothing when there is no context to inject;
  • emits only hookSpecificOutput.additionalContext (no permissionDecision at all) when plan-tune memory context exists.

The deny paths (never-ask auto-decide, Conductor prose redirect) are unchanged.

Tests

Updated assertions across test/question-preference-hook.test.ts, test/memory-cache-injection.test.ts and test/skill-e2e-plan-tune-cathedral.test.ts (defer now = no permissionDecision in output; additionalContext-only output still covered).

bun test test/question-preference-hook.test.ts test/memory-cache-injection.test.ts → 27 pass / 0 fail.

🤖 Generated with Claude Code

…rence-hook

'defer' is a real permissionDecision value in Claude Code, but it means
'pause this tool call and hand control back' and is honored in
print/non-interactive mode (interactive mode warns and ignores it).
The hook emitted it as its 'no opinion' outcome, which made every
AskUserQuestion call get deferred in non-interactive sessions (e.g. the
Claude Code desktop app): the question UI never rendered and AUQ
appeared completely broken after gstack setup registered the hook.

The neutral outcome for a PreToolUse hook is a silent exit 0 — so defer()
now emits nothing, or only additionalContext (without any
permissionDecision) when there is plan-tune memory context to inject.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@trunk-io

trunk-io Bot commented Jul 3, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@time-attack

time-attack commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

@dpnascimento Please rewrite this version to include the accurate documentation and strict output coverage from PR 1924. Its implementation is otherwise the best current foundation.

manhit96 pushed a commit to manhit96/gstack that referenced this pull request Jul 22, 2026
…erence-hook

Silent pass-through (exit 0, optional additionalContext only) instead of
explicit permissionDecision: 'defer'. Claude Code treats defer as a real
pause/resume decision and honors it in print/non-interactive mode, which
swallowed every AskUserQuestion (no tool_result, resume replay loops).
Fixes the root cause behind garrytan#2006/garrytan#2035/garrytan#2207/garrytan#2292/garrytan#2310.

Merges PR garrytan#2165 (print-mode why comment + foundation) with PR garrytan#1924
(passThrough rename, accurate docs, stricter empty-stdout assertions).
deny paths (never-ask auto-decide, Conductor prose redirect) unchanged.

Co-authored-by: dpnascimento <dpnascimento@users.noreply.github.com>
Co-authored-by: jacksondc <jacksondc@users.noreply.github.com>
@capy-ai

capy-ai Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Thank you for this fix! The bug it addresses (#2340) has since been fixed on main and the issue is closed, so I'm closing this PR as done. Re-verified against current main (v1.91.12.0). If you think part of your change is still missing, reply and we'll reopen. Really appreciate the contribution.

@capy-ai capy-ai Bot closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants