ClaudeAgentOptions dataclass provides comprehensive configuration for both query() and ClaudeSDKClient.
Basic Configuration
Configuration Options
Model and System
str | None
default:"None"
The AI model to use. Examples:
"claude-sonnet-4-5""claude-opus-4-1-20250805""claude-opus-4-20250514"
str | None
default:"None"
Fallback model to use if the primary model fails or is unavailable.
str | SystemPromptPreset | None
default:"None"
System prompt to guide Claude’s behavior. Can be:
- A string with custom instructions
- A
SystemPromptPresetdictionary:
list[SdkBeta]
default:"[]"
Beta features to enable. See Anthropic API beta headers.Example:
["context-1m-2025-08-07"]Working Directory
str | Path | None
default:"None"
Working directory for the conversation. Claude will have access to files in this directory.
list[str | Path]
default:"[]"
Additional directories to give Claude access to beyond the
cwd.Tools Configuration
list[str] | ToolsPreset | None
default:"None"
Tools available to Claude. Can be:
- A list of tool names:
["Bash", "Read", "Write"] - A preset:
{"type": "preset", "preset": "claude_code"} Noneto use default tools
list[str]
default:"[]"
Whitelist of allowed tools. If specified, only these tools will be available.
list[str]
default:"[]"
Blacklist of disallowed tools. These tools will be removed from the available set.
Permissions
PermissionMode | None
default:"None"
Controls tool execution permissions:
"default"- CLI prompts for dangerous tools"acceptEdits"- Auto-accept file edits"plan"- Planning mode (read-only)"bypassPermissions"- Allow all tools (use with caution)
str | None
default:"None"
Tool name to use for permission prompts. Set to
"stdio" when using can_use_tool callback (set automatically by the SDK).CanUseTool | None
default:"None"
Callback function for custom tool permission logic. Must be used with streaming mode (ClaudeSDKClient or AsyncIterable prompt).
Conversation Management
bool
default:"False"
Continue the most recent conversation instead of starting a new one.
str | None
default:"None"
Resume a specific session by session ID.
bool
default:"False"
When resuming, fork to a new session ID rather than continuing the previous session.
bool
default:"False"
Enable file checkpointing to track file changes during the session. Required for
rewind_files().Budget and Limits
int | None
default:"None"
Maximum number of conversation turns before stopping.
float | None
default:"None"
Maximum cost in USD before stopping the conversation.
MCP Servers
dict[str, McpServerConfig] | str | Path
default:"{}"
MCP (Model Context Protocol) server configurations. Can be:
- A dictionary of server configs
- A path to a JSON config file
Hooks
dict[HookEvent, list[HookMatcher]] | None
default:"None"
Hook callbacks for intercepting tool use and other events. See Hooks documentation for details.
Agents
dict[str, AgentDefinition] | None
default:"None"
Custom agent definitions for specialized tasks.
Thinking Configuration
ThinkingConfig | None
default:"None"
Controls extended thinking behavior. Overrides
max_thinking_tokens if set.int | None
default:"None"
Deprecated: Use
thinking instead. Maximum tokens for thinking blocks.Literal['low', 'medium', 'high', 'max'] | None
default:"None"
Effort level for thinking depth.
Structured Output
dict[str, Any] | None
default:"None"
Output format for structured outputs. Matches Messages API structure.Access the structured output in the
ResultMessage:Sandbox Configuration
SandboxSettings | None
default:"None"
Sandbox settings for bash command isolation (macOS/Linux only). Filesystem and network restrictions are configured via permission rules, not via these settings.
Advanced Options
str | Path | None
default:"None"
Path to the Claude Code CLI executable. If not specified, searches in PATH.
str | None
default:"None"
Path to custom settings file.
list[SettingSource] | None
default:"None"
Setting sources to load:
["user", "project", "local"]str | None
default:"None"
User identifier for the session.
dict[str, str]
default:"{}"
Environment variables to pass to the CLI process.
dict[str, str | None]
default:"{}"
Pass arbitrary CLI flags. Keys are flag names (without
--), values are flag values or None for boolean flags.int | None
default:"None"
Maximum bytes when buffering CLI stdout.
bool
default:"False"
Include partial message updates (StreamEvent) during streaming.
Callable[[str], None] | None
default:"None"
Callback for stderr output from the CLI.
Any
default:"sys.stderr"
Deprecated: Use
stderr callback instead. File-like object for debug output.list[SdkPluginConfig]
default:"[]"
Plugin configurations for custom plugins.