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