Skip to main content
The ClaudeAgentOptions dataclass provides comprehensive configuration for both query() and ClaudeSDKClient.

Basic Configuration

Configuration Options

Model and System

model
str | None
default:"None"
The AI model to use. Examples:
  • "claude-sonnet-4-5"
  • "claude-opus-4-1-20250805"
  • "claude-opus-4-20250514"
If not specified, uses the default model from Claude Code.
fallback_model
str | None
default:"None"
Fallback model to use if the primary model fails or is unavailable.
system_prompt
str | SystemPromptPreset | None
default:"None"
System prompt to guide Claude’s behavior. Can be:
  • A string with custom instructions
  • A SystemPromptPreset dictionary:
betas
list[SdkBeta]
default:"[]"
Beta features to enable. See Anthropic API beta headers.Example: ["context-1m-2025-08-07"]

Working Directory

cwd
str | Path | None
default:"None"
Working directory for the conversation. Claude will have access to files in this directory.
add_dirs
list[str | Path]
default:"[]"
Additional directories to give Claude access to beyond the cwd.

Tools Configuration

tools
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"}
  • None to use default tools
allowed_tools
list[str]
default:"[]"
Whitelist of allowed tools. If specified, only these tools will be available.
disallowed_tools
list[str]
default:"[]"
Blacklist of disallowed tools. These tools will be removed from the available set.

Permissions

permission_mode
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)
permission_prompt_tool_name
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).
can_use_tool
CanUseTool | None
default:"None"
Callback function for custom tool permission logic. Must be used with streaming mode (ClaudeSDKClient or AsyncIterable prompt).

Conversation Management

continue_conversation
bool
default:"False"
Continue the most recent conversation instead of starting a new one.
resume
str | None
default:"None"
Resume a specific session by session ID.
fork_session
bool
default:"False"
When resuming, fork to a new session ID rather than continuing the previous session.
enable_file_checkpointing
bool
default:"False"
Enable file checkpointing to track file changes during the session. Required for rewind_files().

Budget and Limits

max_turns
int | None
default:"None"
Maximum number of conversation turns before stopping.
max_budget_usd
float | None
default:"None"
Maximum cost in USD before stopping the conversation.

MCP Servers

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

hooks
dict[HookEvent, list[HookMatcher]] | None
default:"None"
Hook callbacks for intercepting tool use and other events. See Hooks documentation for details.

Agents

agents
dict[str, AgentDefinition] | None
default:"None"
Custom agent definitions for specialized tasks.

Thinking Configuration

thinking
ThinkingConfig | None
default:"None"
Controls extended thinking behavior. Overrides max_thinking_tokens if set.
max_thinking_tokens
int | None
default:"None"
Deprecated: Use thinking instead. Maximum tokens for thinking blocks.
effort
Literal['low', 'medium', 'high', 'max'] | None
default:"None"
Effort level for thinking depth.

Structured Output

output_format
dict[str, Any] | None
default:"None"
Output format for structured outputs. Matches Messages API structure.
Access the structured output in the ResultMessage:

Sandbox Configuration

sandbox
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

cli_path
str | Path | None
default:"None"
Path to the Claude Code CLI executable. If not specified, searches in PATH.
settings
str | None
default:"None"
Path to custom settings file.
setting_sources
list[SettingSource] | None
default:"None"
Setting sources to load: ["user", "project", "local"]
user
str | None
default:"None"
User identifier for the session.
env
dict[str, str]
default:"{}"
Environment variables to pass to the CLI process.
extra_args
dict[str, str | None]
default:"{}"
Pass arbitrary CLI flags. Keys are flag names (without --), values are flag values or None for boolean flags.
max_buffer_size
int | None
default:"None"
Maximum bytes when buffering CLI stdout.
include_partial_messages
bool
default:"False"
Include partial message updates (StreamEvent) during streaming.
stderr
Callable[[str], None] | None
default:"None"
Callback for stderr output from the CLI.
debug_stderr
Any
default:"sys.stderr"
Deprecated: Use stderr callback instead. File-like object for debug output.
plugins
list[SdkPluginConfig]
default:"[]"
Plugin configurations for custom plugins.

Complete Example