Dispatch beta: enable user-defined PreToolUse / output hooks for SendUserMessage (deterministic guardrails)
Background
Cowork dispatch runs on top of Claude Code, which natively supports PreToolUse / PostToolUse hooks as a deterministic control layer. However, user hooks defined in ~/.claude/settings.json are NOT loaded inside the dispatch sandbox (see #40495), so dispatch users currently have zero deterministic guardrails — they can only rely on prompts in CLAUDE.md / Memory.md / user_preferences.
Real-world failure case (2026-05-09)
User defined an explicit, hard-rule banned-phrase list in CLAUDE.md (e.g. "觀察一週", "先評估", "觀察期" — phrases that produce vague non-actionable responses). Within a single session, the dispatcher violated the rule three times in a row. Standard transformer attention drift over long context — exactly the failure mode hooks are designed to mitigate.
This is a known limitation of pure-prompt enforcement: Anthropic's own long-context guidance acknowledges instructions get diluted as context grows, and published research on instruction-following degradation supports this. Hooks are the documented escape hatch — and they're unavailable in dispatch.
Why client-side hooks are necessary
- Prompts are probabilistic, hooks are deterministic. No amount of prompt engineering reaches 100% rule compliance.
- Non-coder dispatch users have no escape hatch. Coders on Claude Code CLI can write hooks; dispatch beta users (often the target audience for "AI without code") cannot.
- Brand / compliance / safety use cases. MSPs, regulated industries, and any user with hard rules need a validator layer on dispatcher output.
Proposed implementation
- Mount / copy
~/.claude/settings.json(and.claude/settings.local.json) into the dispatch sandbox at session start, OR - Provide a dispatch-specific hooks config path (e.g.
~/.claude/cowork-hooks.json) with documented schema - At minimum: support PreToolUse hook on
SendUserMessageso users can validate / block / rewrite dispatcher output before it reaches the chat UI - Document the dispatch hook surface in the Cowork docs (currently undocumented)
Impact if not addressed
Dispatch becomes unsuitable for any user with hard compliance rules, brand voice enforcement, or banned-phrase requirements — i.e. the exact professional use cases Cowork is positioned for.
References
- Hooks guide: https://code.claude.com/docs/en/hooks-guide
- Related bug: https://github.com/anthropics/claude-code/issues/40495
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗