anthropics / anthropics/claude-agent-sdk-python
bypassPermissions mode does not execute settings.json shell hooks
- Linguagem predominante
- Python
- Estrelas
- 8.1k
- Forks
- 1.3k
- Merge médio
- 2d 31min
- PRs com merge (30d)
- 1
Descrição
## 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)
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Avaliação
Esta issue ainda não foi avaliada.