Sign in
Explore
Add-ons · HookEveryday codingReviewed

auq-error-fallback-hook.ts

PostToolUse hook for AskUserQuestion. When that call fails, it reminds the model of the fallback rule for the session kind.

Kind
Hook
Works with
Claude Code
Languages
TypeScript / JavaScript
Source
garrytan/gstack @ 01593aa67c94
Path
hosts/claude/hooks/auq-error-fallback-hook.ts
License
MIT
Jobs
Guardrails
InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
#!/usr/bin/env bun
/**
 * PostToolUse hook for AskUserQuestion — runtime reliability layer for the
 * AUQ-failure prose fallback (OV3:B).
 *
 * When an AskUserQuestion call comes back as an ERROR / missing result (the
 * Conductor MCP bug returns `[Tool result missing due to internal error]`), this
 * hook injects `additionalContext` reminding the model of the failure-fallback
 * rule, tailored to the session kind. It does NOT render the prose itself — the
 * model still emits it. The hook only guarantees the reminder fires at the moment
 * of failure, instead of relying on the model noticing the error result and
 * recalling the echoed SESSION_KIND.
 *
 * DEFENSIVE / INERT-IF-UNSUPPORTED: it is unverified whether Claude Code invokes
 * PostToolUse hooks when an MCP tool returns a transport/missing-result error (we
 * could not force that Conductor-internal failure in a harness — see
 * docs/spikes/claude-code-hook-mutation.md §"PostToolUse on tool error"). If the
 * platform does NOT fire the hook on that path, this is simply never invoked — no
 * harm; the prompt-level fallback in generate-ask-user-format.ts still covers it.
…