Skip to content

Conversation

@ollie-anthropic
Copy link
Collaborator

Adds programmatic sandbox configuration to the Python SDK, matching the TypeScript SDK's approach.

Changes:

  • Add SandboxSettings, SandboxNetworkConfig, SandboxIgnoreViolations types
  • Add sandbox field to ClaudeAgentOptions
  • Merge sandbox into --settings CLI flag in SubprocessCLITransport
  • Export sandbox types from package init.py
  • Add comprehensive tests for sandbox settings

Important: Filesystem and network restrictions are configured via permission rules (Read/Edit/WebFetch), not via these sandbox settings. The sandbox settings control sandbox behavior (enabled, auto-allow, excluded commands, etc.).

Example usage:

from claude_agent_sdk import query, SandboxSettings

result = query(
    prompt='Build and test the project',
    options=ClaudeAgentOptions(
        sandbox={
            'enabled': True,
            'autoAllowBashIfSandboxed': True,
            'excludedCommands': ['docker'],
            'network': {
                'allowLocalBinding': True,
                'allowUnixSockets': ['/var/run/docker.sock']
            }
        }
    )
)

Adds programmatic sandbox configuration to the Python SDK, matching the
TypeScript SDK's approach.

Changes:
- Add SandboxSettings, SandboxNetworkConfig, SandboxIgnoreViolations types
- Add sandbox field to ClaudeAgentOptions
- Merge sandbox into --settings CLI flag in SubprocessCLITransport
- Export sandbox types from package __init__.py
- Add comprehensive tests for sandbox settings

**Important:** Filesystem and network restrictions are configured via permission
rules (Read/Edit/WebFetch), not via these sandbox settings. The sandbox settings
control sandbox behavior (enabled, auto-allow, excluded commands, etc.).

Example usage:
```python
from claude_agent_sdk import query, SandboxSettings

result = query(
    prompt='Build and test the project',
    options=ClaudeAgentOptions(
        sandbox={
            'enabled': True,
            'autoAllowBashIfSandboxed': True,
            'excludedCommands': ['docker'],
            'network': {
                'allowLocalBinding': True,
                'allowUnixSockets': ['/var/run/docker.sock']
            }
        }
    )
)
```
@ollie-anthropic ollie-anthropic changed the title Create sandbox adapter interface for SDK Create sandbox adapter interface for Python SDK Nov 24, 2025
@ollie-anthropic ollie-anthropic merged commit f21f63e into main Dec 1, 2025
28 checks passed
@ollie-anthropic ollie-anthropic deleted the claude/sandbox-adapter-interface-01VoWfV535SjuizsY2TrwQeo branch December 1, 2025 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants