Agent SDK reference - Python changedagent-sdk/python
Upstream edited this page at 28 Nov 2026 19:04 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 28 Nov 2026 19:07 UTC.
Upstream edited
Recorded here
Lines+2added
Lines−2removed
From line
896
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits93to this page, all time
The whole hunk
from line 896, old and new numbered
/
from line 896
896896| `stderr` | `Callable[[str], None] \| None` | `None` | Callback function for stderr output from CLI |
897897| `can_use_tool` | [`CanUseTool`](#canusetool) ` \| None` | `None` | Tool permission callback, invoked only when the [permission flow](https://code.claude.com/docs/en/agent-sdk/permissions.md#how-permissions-are-evaluated) falls through to a prompt. Not invoked for calls auto-approved by `allowed_tools`, allow rules, or `permission_mode`. An allow rule doesn't pre-approve the [actions no mode auto-approves](https://code.claude.com/docs/en/permission-modes.md#actions-no-mode-auto-approves). See [`CanUseTool`](#canusetool) for details |
898898| `hooks` | `dict[HookEvent, list[HookMatcher]] \| None` | `None` | Hook configurations for intercepting events |
899| `user` | `str \| None` | `None` | On POSIX platforms, the OS user account the Claude Code subprocess runs as. Claude Code keeps the parent process's environment, including `HOME`, and runs in `cwd` |
899| `user` | `str \| None` | `None` | On POSIX platforms, the OS user account the Claude Code subprocess runs as. Claude Code keeps the parent process's groups and environment, including `HOME`, and runs in `cwd` |
900900| `include_partial_messages` | `bool` | `False` | Include partial message streaming events. When enabled, [`StreamEvent`](#streamevent) messages are yielded |
901901| `include_hook_events` | `bool` | `False` | Include hook lifecycle events in the message stream as `HookEventMessage` objects |
902902| `forward_subagent_text` | `bool` | `False` | Forward subagent text and thinking blocks in the message stream. Without this option, Claude Code omits the text and thinking blocks of a subagent that runs in the [foreground](https://code.claude.com/docs/en/sub-agents.md#run-subagents-in-foreground-or-background). For nested subagents, skills with `context: fork`, and the Claude Code version each needs, see [Follow subagent messages](https://code.claude.com/docs/en/headless.md#follow-subagent-messages). Requires Python Agent SDK 0.2.140 or later |
from line 2946
29462946}
29472947```
29482948
2949**Output (type: `"file_unchanged"`):**
2949**Output (type: `"file_unchanged"`), before Claude Code v2.1.317:**
29502950
29512951```python theme={null}
29522952{
No line in this hunk matches that.