anthropics / anthropics/claude-agent-sdk-python

bypassPermissions mode does not execute settings.json shell hooks

オープン
#768 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
8.1k
フォーク
1.3k
平均マージ
2日 31分
マージ済み PR(30日)
1

説明

## Description

When using `permission_mode="bypassPermissions"`, shell hooks configured in `~/.claude/settings.json` are never executed. The PreToolUse hook for AskUserQuestion (configured as a shell command) never fires.

## Steps to Reproduce

1. Configure a PreToolUse hook in `~/.claude/settings.json`:
```json
{
"hooks": {
"PreToolUse": [{
"matcher": "AskUserQuestion",
"hooks": [{"type": "command", "command": "/path/to/hook.sh"}]
}]
}
}
```

2. Run a query that triggers AskUserQuestion:
```python
options = ClaudeAgentOptions(
permission_mode="bypassPermissions",
cli_path="/home/tester/.local/bin/claude",
)
async for msg in query(prompt="Ask my name with AskUserQuestion", options=options):
pass
```

3. The hook script is never called (verified via logs and lack of HTTP calls from the hook).

The same hook fires correctly when running `claude --print --dangerously-skip-permissions -p "..."` directly.

## Expected Behavior

Shell hooks from settings.json should still fire in `bypassPermissions` mode. Permission bypass should skip the interactive permission prompt, not skip all hooks.

## Workaround

Use Python hook callbacks via the `hooks` parameter in `ClaudeAgentOptions` instead of shell hooks in settings.json.

## Environment

- claude-agent-sdk: 0.1.51
- Claude CLI: 2.1.86
- Python: 3.12
- OS: Linux (Docker)

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。