[Bug] Hardcoded Default Values Scattered in Sandbox Configuration
- Dominant language
- Python
- Stars
- 485
- Forks
- 81
- Avg merge
- 16h 12m
- Merged PRs (30d)
- 8
Description
## Bug Description
The Python SDK contains numerous hardcoded default values in `sdk/sandbox/config.py` and `sdk/sandbox/client.py`. These values cannot be customized via environment variables, reducing flexibility for different deployment scenarios.
Key hardcoded values include:
### In `sdk/sandbox/config.py`:
| Configuration | Hardcoded Value | Line |
|---------------|-----------------|------|
| `image` | `"python:3.11"` | L23 |
| `auto_clear_seconds` | `60 * 5` (300) | L24 |
| `memory` | `"8g"` | L27 |
| `cpus` | `2` | L28 |
| `cluster` | `"zb"` | L31 |
| `size` (SandboxGroup) | `2` | L35 |
| `start_concurrency` | `2` | L36 |
| `start_retry_times` | `3` | L37 |
### In `sdk/sandbox/client.py`:
| Configuration | Hardcoded Value | Location |
|---------------|-----------------|----------|
| Status check interval | `3` seconds | `await asyncio.sleep(3)` in `start()` |
| `wait_timeout` default | `300` seconds | `arun()` parameter |
| `wait_interval` default | `10` seconds | `arun()` parameter |
| Nohup command timeout | `30` seconds | `BashAction(..., timeout=30)` |
| Minimum check interval | `5` seconds | `max(5, wait_interval)` |
## Steps to Reproduce
1. Review the source code at `sdk/sandbox/config.py` and `sdk/sandbox/client.py`
2. Observe that default values are directly embedded in the code
3. Try to change `cluster` default from `"zb"` to another cluster without modifying code - not possible via environment variable
## Expected Behavior
- Default values should be configurable via environment variables (e.g., `ROCK_DEFAULT_CLUSTER`, `ROCK_DEFAULT_IMAGE`, `ROCK_DEFAULT_MEMORY`, `ROCK_DEFAULT_CPUS`)
- The `env_vars.py` module should support these configuration environment variables with sensible fallback defaults
- Consistency with existing pattern: `ROCK_BASE_URL`, `ROCK_SANDBOX_STARTUP_TIMEOUT_SECONDS` are already configurable via environment variables
## Actual Behavior
- `cluster` defaults to `"zb"` - a China-specific cluster that may not be appropriate for international users or different deployment environments
- Resource defaults (`memory=8g`, `cpus=2`) may not suit all use cases
- No way to change these defaults without modifying the source code
## Suggested Solution
1. Add new environment variables to `env_vars.py`:
```python
"ROCK_DEFAULT_CLUSTER": lambda: os.getenv("ROCK_DEFAULT_CLUSTER", "zb"),
"ROCK_DEFAULT_IMAGE": lambda: os.getenv("ROCK_DEFAULT_IMAGE", "python:3.11"),
"ROCK_DEFAULT_MEMORY": lambda: os.getenv("ROCK_DEFAULT_MEMORY", "8g"),
"ROCK_DEFAULT_CPUS": lambda: float(os.getenv("ROCK_DEFAULT_CPUS", "2")),
"ROCK_DEFAULT_AUTO_CLEAR_SECONDS": lambda: int(os.getenv("ROCK_DEFAULT_AUTO_CLEAR_SECONDS", "300")),
```
2. Update `sdk/sandbox/config.py` to use these environment variables:
```python
class SandboxConfig(BaseConfig):
image: str = env_vars.ROCK_DEFAULT_IMAGE
auto_clear_seconds: int = env_vars.ROCK_DEFAULT_AUTO_CLEAR_SECONDS
memory: str = env_vars.ROCK_DEFAULT_MEMORY
cpus: float = env_vars.ROCK_DEFAULT_CPUS
cluster: str = env_vars.ROCK_DEFAULT_CLUSTER
# ...
```
## Error Logs
N/A - This is a configuration flexibility issue, not a runtime error.
## Environment Information
- **OS**: Any
- **Python Version**: Any
- **ROCK Version**: Current (as of March 2026)
- **Installation Method**: pip install rl-rock
- **Docker Version**: N/A
- **Deployment Type**: Any
## ROCK Configuration
- **Runtime Environment Type**: Any
- **Sandbox Image**: Default `python:3.11`
- **Resource Allocation**: Default `memory=8g, cpus=2`
## Component Affected
- [x] Sandbox
- [ ] Actions
- [ ] Deployments
- [x] SDK & API
- [ ] Envhub
- [ ] CLI
- [ ] Performance & Optimization
- [ ] Documentation & Examples
---
## Additional Context
This issue was identified during the TypeScript SDK code review (PR #492). The TypeScript SDK mirrors the Python SDK's behavior and has the same hardcoded defaults. Fixing this in the Python SDK would also guide the TypeScript SDK implementation.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading sdk/sandbox/config.py, sdk/sandbox/client.py, and env_vars.py, then compare the existing ROCK_BASE_URL and ROCK_SANDBOX_STARTUP_TIMEOUT_SECONDS configuration patterns. Check each listed default and its use in SandboxConfig and client methods. Done means the specified defaults remain unchanged when unset and can be overridden through the proposed environment variables.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100