options
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| AskUserQuestionToolConfig clawd_code_sdk.models.options Configuration for the AskUserQuestion tool. |
||
| BaseSessionConfig clawd_code_sdk.models.options Common fields for all session configurations. |
||
| ClaudeAgentOptions clawd_code_sdk.models.options Query options for Claude SDK. |
||
| ContinueLatest clawd_code_sdk.models.options Continue the most recent conversation. |
||
| FromPR clawd_code_sdk.models.options Resume sessions linked to a specific GitHub PR. |
||
| NewSession clawd_code_sdk.models.options Start a fresh session. |
||
| ResumeSession clawd_code_sdk.models.options Resume an existing session by ID. |
||
| ToolConfig clawd_code_sdk.models.options Per-tool configuration for built-in tools. |
🛈 DocStrings¶
ClaudeAgentOptions and session configuration types.
SessionConfig
module-attribute
¶
SessionConfig = NewSession | ResumeSession | ContinueLatest | FromPR
Union of all session configuration types.
Can also be specified as a plain str, which is a shortcut for
ResumeSession(session_id=str).
AskUserQuestionToolConfig
dataclass
¶
Configuration for the AskUserQuestion tool.
Source code in src/clawd_code_sdk/models/options.py
preview_format
class-attribute
instance-attribute
¶
Content format for the preview field on question options.
BaseSessionConfig
dataclass
¶
Common fields for all session configurations.
Source code in src/clawd_code_sdk/models/options.py
persist
class-attribute
instance-attribute
¶
Whether to persist the session to disk.
ClaudeAgentOptions
dataclass
¶
Query options for Claude SDK.
Source code in src/clawd_code_sdk/models/options.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 | |
add_dirs
class-attribute
instance-attribute
¶
Add additional working directories.
agent
class-attribute
instance-attribute
¶
Agent name for the main thread. The agent must be defined in agents or settings.
agent_progress_summaries
class-attribute
instance-attribute
¶
Enable periodic AI-generated progress summaries for running subagents.
When True, the subagent's conversation is forked every ~30s to produce a short present-tense description (e.g. 'Analyzing authentication module'), emitted on task_progress events via the summary field. The fork reuses the subagent's model and prompt cache, so cost is typically minimal.
Applies to both foreground and background subagents. Defaults to False.
agents
class-attribute
instance-attribute
¶
agents: dict[str, AgentDefinition] | None = None
SubAgent definitions.
allow_dangerously_skip_permissions
class-attribute
instance-attribute
¶
Must be True when using permission_mode='bypassPermissions'.
allowed_tools
class-attribute
instance-attribute
¶
Tools which execute without prompting for permission.
capture_sdk_mcp_manifests
class-attribute
instance-attribute
¶
Do the in-process MCP servers' handshake before connecting and send its results.
The initialize request then carries each server's initialize and first
tools/list results (sdkMcpServerManifests), so the CLI connects them without
control round trips before the first turn. A server whose handshake fails, or that the
CLI does not take, is handshaken over the control channel as before. Off when the
CLAUDE_AGENT_SDK_DISABLE_MCP_MANIFESTS environment variable is set (as upstream).
chrome
class-attribute
instance-attribute
¶
Add the chrome-tools MCP server (-> Claude Code browser extension) to the agent.
cli_path
class-attribute
instance-attribute
¶
CLI path override (auto-detects by default).
context_1m
class-attribute
instance-attribute
¶
Enable 1M token context window (Sonnet 4/4.5 only).
cwd
class-attribute
instance-attribute
¶
The working directory for the agent.
debug_file
class-attribute
instance-attribute
¶
Write debug logs to a specific file path. Implicitly enables debug mode.
disable_parallel_tool_use
class-attribute
instance-attribute
¶
Disable parallel too use (only one tool_use block per response).
disallowed_tools
class-attribute
instance-attribute
¶
Tools that are removed from agent context and cant be used.
effort
class-attribute
instance-attribute
¶
Effort level for thinking depth.
enable_agent_teams
class-attribute
instance-attribute
¶
Enable the experimental agent teams feature.
enable_file_checkpointing
class-attribute
instance-attribute
¶
Enable file checkpointing to track file changes during the session.
When enabled, files can be rewound to their state at any user message
using ClaudeSDKClient.rewind_files().
enable_tool_search
class-attribute
instance-attribute
¶
Enable or disable MCP tool search.
When many MCP tools are configured, tool definitions can consume a significant portion of the context window. Tool search dynamically loads tools on-demand instead of preloading all of them.
True: Always enabled.False: Always disabled, all MCP tools loaded upfront."auto": Activates when MCP tools exceed 10% of context (default behavior).int: Auto-activates at this percentage threshold (e.g.5for 5%).None(default): Uses Claude Code's default (auto at 10%).
Requires models that support tool_reference blocks (Sonnet 4+, Opus 4+).
env
class-attribute
instance-attribute
¶
Environment variables for the CLI subprocess.
exclude_dynamic_sections
class-attribute
instance-attribute
¶
Whether to exclude dynamic sections from the system prompt.
extra_args
class-attribute
instance-attribute
¶
Arbitrary extra CLI flags.
fallback_model
class-attribute
instance-attribute
¶
Fallback model in case default one is overloaded.
fine_grained_tool_streaming
class-attribute
instance-attribute
¶
Stream tool input to the client as the model writes it (fine-grained tool streaming).
With it, stream_event messages carry tool input JSON as it is generated, so a UI can
show a long Write/Edit input live and the tool call starts sooner. It saves no
tokens. The partial tool input JSON is not validated by the API, and some endpoints
reject the request with HTTP 400 (proxies / gateways, some models on Bedrock and Vertex).
"auto"(default): on when the CLI talks to Anthropic's API directly (noCLAUDE_CODE_USE_BEDROCK/_VERTEX/ other provider env,ANTHROPIC_BASE_URLunset orapi.anthropic.com); otherwise the CLI's own default applies.True/False: force it on / off.
CLAUDE_CODE_ENABLE_FINE_GRAINED_TOOL_STREAMING in env overrides this option.
forward_subagent_text
class-attribute
instance-attribute
¶
Forward subagent text and thinking blocks as messages with parent_tool_use_id set.
By default only tool_use/tool_result blocks from subagents are emitted.
hooks
class-attribute
instance-attribute
¶
hooks: dict[HookEvent, list[HookMatcher]] | None = None
Hook configurations.
include_builtin_system_prompt
class-attribute
instance-attribute
¶
Whether to include Claude Code's builtin system prompt.
When True (default) and system_prompt is set, it is appended to the builtin system prompt. When False, the system_prompt replaces it entirely.
include_hook_events
class-attribute
instance-attribute
¶
Include hook lifecycle events in the output stream.
When True, hook_started, hook_progress, and hook_response system
messages will be emitted for all hook event types. SessionStart and Setup
hook events are always emitted regardless of this setting.
instrument
class-attribute
instance-attribute
¶
Whether to instrument the session with tracing hooks.
max_budget_usd
class-attribute
instance-attribute
¶
Maximum amount of USD budget which may be consumed.
max_buffer_size
class-attribute
instance-attribute
¶
Max bytes when buffering CLI stdout.
max_turns
class-attribute
instance-attribute
¶
Maximum allowed amount of agentic turns.
mcp_servers
class-attribute
instance-attribute
¶
MCP servers for the agent.
mcp_servers_delivery
class-attribute
instance-attribute
¶
How the mcp_servers that Claude Code runs or connects to (stdio, SSE, HTTP) reach it.
"initialize"(default): in the initialize request over stdin (the CLI is started with--await-initialize), so serverenvandheadersstay off the command line, where other users of the machine can read them. Needs Claude Code 2.1.261 or newer; connecting fails if the CLI does not take them (mcp_servers_applied)."argv": in one--mcp-configflag, for older Claude Code. Deprecated upstream.
In-process servers (McpSdkServerConfigWithInstance) and an mcp_servers file path
are not affected, and a launch with --sdk-url in extra_args always uses
--mcp-config, as that session cannot read the request at launch.
on_elicitation
class-attribute
instance-attribute
¶
on_elicitation: OnElicitation | None = None
Callback for handling MCP elicitation requests.
Called when an MCP server requests user input (form fields, URL auth, etc.) and no hook handles the request first.
If not provided, elicitation requests that aren't handled by hooks will be declined automatically.
on_permission
class-attribute
instance-attribute
¶
Permission handler for tool execution.
Accepts either:
- A callback function (CanUseTool): The SDK routes permission requests
through the control protocol to this callback. Automatically adds
--permission-prompt-tool stdio to the CLI.
- A string: Name of an MCP tool to handle permission prompts
(passed as --permission-prompt-tool <name> to the CLI).
- None: Default behavior.
Interaction with permission_mode:
"default": All tool calls are routed to this handler."acceptEdits": All tool calls are routed to this handler. The handler is responsible for implementing the auto-approve-edits policy."plan": Only the syntheticExitPlanModetool is routed here. Actual modification tools are blocked by the CLI before reaching the handler."dontAsk": This handler is NEVER invoked. The CLI auto-denies all tools not pre-approved via the permissions config internally."bypassPermissions": This handler is NEVER invoked. The CLI auto-approves all tools internally.
Tools that allowed_tools allows outright ("Read", "Read()", "Read(*)")
never reach the handler either. Connecting emits a CanUseToolShadowedWarning when
a callback is set together with "bypassPermissions" or such entries.
on_user_question
class-attribute
instance-attribute
¶
on_user_question: OnUserQuestion | None = None
Callback for handling AskUserQuestion elicitation requests.
Called when Claude asks the user a clarifying question via the AskUserQuestion tool. If not set, these requests fall through to on_permission (if it's a callback) for backwards compatibility.
output_schema
class-attribute
instance-attribute
¶
JSON schema for structured output.
Accepts either a JSON schema dict or a Python type (Pydantic model, dataclass, TypedDict, etc.) which will be converted to a JSON schema automatically.
When set, Claude will return responses conforming to this schema.
Examples:
As a dict¶
output_schema={"type": "object", "properties": {"name": {"type": "string"}}}
As a type¶
output_schema=MyPydanticModel
per_task_stop_affordance
class-attribute
instance-attribute
¶
Declare that this consumer can stop individual background tasks (stop_task).
When declared, an interrupt only aborts the current turn and spares running background agents/workflows.
permission_mode
class-attribute
instance-attribute
¶
Permission mode.
permission_prompts
class-attribute
instance-attribute
¶
Who answers permission prompts.
"host" (default): this process, through on_permission.
"none": nobody - permission mode, rules and hooks still decide, and anything
that would otherwise prompt is denied immediately.
plan_mode_instructions
class-attribute
instance-attribute
¶
Custom workflow body for the plan-mode system reminder.
plugin_delivery
class-attribute
instance-attribute
¶
How plugins reach Claude Code.
"argv"(default): one--plugin-dirflag per plugin. Works with any Claude Code version, but the command line grows with the plugin count (Windows refuses one past 32,767 characters)."initialize": in the initialize request over stdin (the CLI is started with--await-initialize); connecting fails if the CLI does not load them (plugins_applied). A launch with--sdk-urlinextra_argsalways uses argv.
plugins
class-attribute
instance-attribute
¶
plugins: list[SdkPluginConfig] = field(default_factory=list)
"Plugin configurations to load.
project_config_root
class-attribute
instance-attribute
¶
The trusted checkout that cwd is a worktree of.
Project settings, .mcp.json, the .claude config trees and
CLAUDE_PROJECT_DIR come from here instead of cwd. Absolute path.
prompt_suggestions
class-attribute
instance-attribute
¶
Whether to create prompt suggestions.
replay_user_messages
class-attribute
instance-attribute
¶
Whether to replay user messages in the session.
sandbox
class-attribute
instance-attribute
¶
sandbox: Sandbox | None = None
Sandbox configuration for bash command isolation.
Filesystem and network restrictions are derived from permission rules (Read/Edit/WebFetch), not from these sandbox settings.
session
class-attribute
instance-attribute
¶
session: str | SessionConfig | None = None
Session configuration.
Controls how the CLI session is started:
- None or NewSession(): Start a fresh session.
- "session-id" or ResumeSession(session_id="..."): Resume by ID.
- ContinueLatest(): Continue the most recent conversation.
setting_sources
class-attribute
instance-attribute
¶
Sources to load filesystem settings from.
None loads the CLI's defaults (user, project, local); [] loads none.
settings
class-attribute
instance-attribute
¶
settings: str | Path | ClaudeCodeSettings | None = None
Settings configuration.
Accepts:
- A str or Path: interpreted as a path to a settings JSON file.
- A ClaudeCodeSettings instance: serialized to JSON automatically.
- None: no explicit settings.
skills
class-attribute
instance-attribute
¶
List of skills to use for the agent.
stderr
class-attribute
instance-attribute
¶
Callback for stderr output from CLI.
strict_mcp_config
class-attribute
instance-attribute
¶
Enforce strict validation of MCP server configurations.
system_prompt
class-attribute
instance-attribute
¶
System prompt for the agent.
system_prompt_snapshot
class-attribute
instance-attribute
¶
Snapshot the system prompt on the first request and reuse it verbatim.
Keeps the prompt byte-identical across requests and resumes (better cache hits).
task_budget
class-attribute
instance-attribute
¶
API-side task budget in tokens.
When set, the model is made aware of its remaining token budget so it can
pace tool use and wrap up before the limit. The CLI sends this as
output_config.task_budget with the task-budgets-2026-03-13 beta
header automatically.
thinking
class-attribute
instance-attribute
¶
Controls thinking behavior.
tool_aliases
class-attribute
instance-attribute
¶
Redirect built-in tool names to other tools, e.g. {"Bash": "mcp__ws__bash"}.
Single-hop; complementary to disallowed_tools, not a replacement.
tool_config
class-attribute
instance-attribute
¶
tool_config: ToolConfig | None = None
Per-tool configuration for built-in tools.
tools
class-attribute
instance-attribute
¶
tools: list[ToolName | str] | ToolsPreset | None = None
Tools available to the agent.
verbatim_prompts
class-attribute
instance-attribute
¶
Send every user message with client_composed: true.
The CLI then delivers the prompt text as written: no @path expansion and
no slash-command dispatch. Requires Claude Code 2.1.248+.
worktree
class-attribute
instance-attribute
¶
Create a new git worktree for the session (with optional name).
argv_mcp_servers
¶
The servers for --mcp-config.
All of them, or only the in-process ones when the others go in the initialize request.
Source code in src/clawd_code_sdk/models/options.py
build_settings_value
¶
Build the CLI --settings value, merging sandbox if provided.
Returns:
| Type | Description |
|---|---|
str | None
|
A JSON string, a file path, or None. |
Source code in src/clawd_code_sdk/models/options.py
initialize_mcp_servers
¶
The servers to send in the initialize request, or None to send none there.
Source code in src/clawd_code_sdk/models/options.py
initialize_plugins
¶
The plugins to send in the initialize request, or None to pass them as flags.
Source code in src/clawd_code_sdk/models/options.py
reads_initialize_at_launch
¶
Whether the CLI waits for the initialize request (--await-initialize).
sdk_mcp_server_configs
¶
Settings of the in-process MCP servers (timeout, tool policy), by server name.
Source code in src/clawd_code_sdk/models/options.py
ContinueLatest
dataclass
¶
Bases: BaseSessionConfig
Continue the most recent conversation.
Source code in src/clawd_code_sdk/models/options.py
fork
class-attribute
instance-attribute
¶
If True, fork to a new session ID instead of continuing in-place.
FromPR
dataclass
¶
Bases: BaseSessionConfig
Resume sessions linked to a specific GitHub PR.
Accepts a PR number or URL. Sessions are automatically linked
when created via gh pr create.
Source code in src/clawd_code_sdk/models/options.py
NewSession
dataclass
¶
Bases: BaseSessionConfig
Start a fresh session.
Source code in src/clawd_code_sdk/models/options.py
ResumeSession
dataclass
¶
Bases: BaseSessionConfig
Resume an existing session by ID.
Source code in src/clawd_code_sdk/models/options.py
at_message
class-attribute
instance-attribute
¶
Resume from a specific message UUID within the session.
drops_turn
class-attribute
instance-attribute
¶
Guard for truncating resume (--resume-drops-turn).
Declares the user message UUID of the turn that at_message is expected to
drop. The CLI refuses the resume if the truncation would discard anything else.
Only meaningful together with at_message.
fork
class-attribute
instance-attribute
¶
If True, fork to a new session ID instead of continuing in-place.