claude-code-sdk-python/examples
Ashwin Bhat e8d7e71a0a
Add missing hook output fields to match TypeScript SDK (#226)
Closes the gap between Python and TypeScript SDK hook output types by
adding:
- `reason` field for explaining decisions
- `continue_` field for controlling execution flow
- `suppressOutput` field for hiding stdout
- `stopReason` field for stop explanations
- `decision` now supports both "approve" and "block" (not just "block")
- `AsyncHookJSONOutput` type for deferred hook execution
- Proper typing for `hookSpecificOutput` with discriminated unions

Also adds comprehensive examples and tests:
- New examples in hooks.py demonstrating all new fields
- Unit tests in test_tool_callbacks.py for new output types
- E2E tests in e2e-tests/test_hooks.py with real API calls
- CI integration in .github/workflows/test.yml

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-09 18:13:23 -07:00
..
agents.py Rename claude_code to claude_agent (#188) 2025-09-28 14:52:53 -07:00
hooks.py Add missing hook output fields to match TypeScript SDK (#226) 2025-10-09 18:13:23 -07:00
include_partial_messages.py Update model references to claude-sonnet-4-5 (#198) 2025-09-30 12:59:14 -07:00
mcp_calculator.py Rename claude_code to claude_agent (#188) 2025-09-28 14:52:53 -07:00
quick_start.py Rename claude_code to claude_agent (#188) 2025-09-28 14:52:53 -07:00
setting_sources.py Rename claude_code to claude_agent (#188) 2025-09-28 14:52:53 -07:00
stderr_callback_example.py Rename claude_code to claude_agent (#188) 2025-09-28 14:52:53 -07:00
streaming_mode.py Update model references to claude-sonnet-4-5 (#198) 2025-09-30 12:59:14 -07:00
streaming_mode_ipython.py Rename claude_code to claude_agent (#188) 2025-09-28 14:52:53 -07:00
streaming_mode_trio.py Update model references to claude-sonnet-4-5 (#198) 2025-09-30 12:59:14 -07:00
system_prompt.py Rename claude_code to claude_agent (#188) 2025-09-28 14:52:53 -07:00
tool_permission_callback.py Rename claude_code to claude_agent (#188) 2025-09-28 14:52:53 -07:00