claude-code - 💡(How to fix) Fix Dispatch beta: enable user-defined PreToolUse / output hooks for SendUserMessage (deterministic guardrails)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fix / Workaround

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.

RAW_BUFFERClick to expand / collapse

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

  1. Prompts are probabilistic, hooks are deterministic. No amount of prompt engineering reaches 100% rule compliance.
  2. 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.
  3. 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 SendUserMessage so 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

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING