examples/claude-agent-sdk/advanced-options/README.md
This example demonstrates advanced Claude Agent SDK configuration options including sandbox settings, runtime configuration, and CLI arguments.
npx promptfoo@latest init --example claude-agent-sdk/advanced-options
cd claude-agent-sdk/advanced-options
Install the Claude Agent SDK:
npm install @anthropic-ai/claude-agent-sdk
Export your Anthropic API key:
export ANTHROPIC_API_KEY=your_api_key_here
cd advanced-options && promptfoo eval
Run commands in a sandboxed environment for additional security:
providers:
- id: anthropic:claude-agent-sdk
config:
sandbox:
enabled: true
autoAllowBashIfSandboxed: true
network:
allowLocalBinding: true
allowedDomains:
- api.example.com
Specify the JavaScript runtime:
providers:
- id: anthropic:claude-agent-sdk
config:
executable: bun # or 'node' or 'deno'
executable_args:
- '--smol'
Pass additional arguments to Claude Code:
providers:
- id: anthropic:claude-agent-sdk
config:
extra_args:
verbose: null # boolean flag (adds --verbose)
timeout: '30' # adds --timeout 30
Control where the SDK looks for settings:
providers:
- id: anthropic:claude-agent-sdk
config:
setting_sources:
- user # ~/.claude/settings.json
- project # .claude/settings.json
- local # .claude/settings.local.json
For automated testing scenarios that require bypassing permissions:
providers:
- id: anthropic:claude-agent-sdk
config:
permission_mode: bypassPermissions
allow_dangerously_skip_permissions: true # Required safety flag
Route permission prompts through an MCP tool:
providers:
- id: anthropic:claude-agent-sdk
config:
permission_prompt_tool_name: my-mcp-permission-tool
Use a specific Claude Code installation:
providers:
- id: anthropic:claude-agent-sdk
config:
path_to_claude_code_executable: /custom/path/to/claude-code
| Option | Type | Description |
|---|---|---|
sandbox | object | Sandbox settings for command execution isolation |
sandbox.enabled | boolean | Enable sandboxed execution |
sandbox.autoAllowBashIfSandboxed | boolean | Auto-allow bash when sandboxed |
sandbox.failIfUnavailable | boolean | Fail closed if sandbox support is unavailable |
sandbox.network | object | Network configuration for sandbox |
sandbox.network.allowedDomains | string[] | Domains allowed for network access |
sandbox.network.allowLocalBinding | boolean | Allow binding to localhost |
allow_dangerously_skip_permissions | boolean | Required for bypassPermissions mode |
permission_prompt_tool_name | string | MCP tool for permission prompts |
executable | 'node' | 'bun' | 'deno' | JavaScript runtime to use |
executable_args | string[] | Arguments for the runtime |
extra_args | Record<string, string|null> | Additional CLI arguments |
path_to_claude_code_executable | string | Path to Claude Code executable |