-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Checklist
- This feature will maintain backward compatibility with the current sdk.
Background
Feature Request: Claude-Compatible Sandbox Environment
We need to implement a sandbox execution environment that complies with the Claude Agent SDK's sandbox provider interface standards. This will enable secure, isolated code execution for AI agents similar to Modal's Sandbox API.
Use Case: Support Claude AI agents in executing arbitrary code safely within containerized environments, providing:
- Secure isolated execution environments
- File system access control
- Network isolation
- Resource limits (CPU, memory, timeout)
- Standard I/O capture
Reference:
- Modal Sandbox API: https://modal.com/docs/guide/sandboxes
- Claude Agent SDK Sandbox Standards: https://platform.claude.com/docs/en/agent-sdk/hosting#sandbox-provider-options
Potential Solution
Implement a sandbox provider interface that includes:
Core Components:
-
Sandbox Creation API
- Create ephemeral containers with specified runtime environments
- Support multiple language runtimes (Python, Node.js, etc.)
- Configure resource limits and timeouts
-
Code Execution Interface
class SandboxProvider: async def create_sandbox(self, image: str, **kwargs) -> Sandbox async def execute(self, code: str, timeout: int) -> ExecutionResult async def cleanup(self) -> None
-
File System Operations
- Upload files to sandbox
- Download results from sandbox
- Read/write operations within isolated filesystem
-
Process Management
- Execute commands with stdin/stdout/stderr capture
- Support for long-running processes
- Graceful termination and cleanup
Implementation Approach:
- Leverage existing Kubernetes infrastructure in AEnvironment
- Use container orchestration for sandbox lifecycle management
- Implement gRPC/REST API endpoints matching Claude's sandbox interface
- Add security policies: network isolation, resource quotas, execution timeouts
- Provide standard base images with common dependencies pre-installed
Similar Features in Other Frameworks:
- Modal Sandboxes: Ephemeral containers with timeout-based lifecycle
- E2B Code Interpreter: Isolated Python execution environments
- Kubernetes Jobs: Similar isolation but heavier weight
- Docker-in-Docker: Container-based isolation with nested containers
Additional Information
Requirements:
- Maintain backward compatibility with existing AEnvironment SDK
- Support multiple concurrent sandbox sessions
- Implement proper resource cleanup to prevent leaks
- Add monitoring and logging for sandbox operations
- Provide clear error handling and timeout mechanisms
Technical Considerations:
- Integration with existing controller and API service architecture
- Security: Container escape prevention, privilege restrictions
- Performance: Fast container startup times (<2s ideal)
- Cost: Efficient resource utilization and auto-scaling
References:
- Claude Agent SDK Hosting Docs: https://platform.claude.com/docs/en/agent-sdk/hosting
- Modal Sandbox Documentation: https://modal.com/docs/guide/sandboxes
- Container Security Best Practices: https://kubernetes.io/docs/concepts/security/pod-security-standards/
Metadata
Metadata
Assignees
Labels
No labels