boxlite-ai / boxlite-ai/boxlite

Support box restart policies

Open
#32 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2.3k
Forks
179
Avg merge
23h 25m
Merged PRs (30d)
121

Description

## Summary
Add restart policies to automatically restart boxes on crash or exit.

## Use Cases
- Long-running AI agents that should auto-recover
- Development servers that restart on crash
- Resilient service deployments

## Proposed API

### Rust
```rust
pub enum RestartPolicy {
No, // Never restart (default)
Always, // Always restart
OnFailure { max_retries: u32 }, // Restart on non-zero exit
UnlessStopped, // Restart unless explicitly stopped
}

let options = BoxOptions {
restart_policy: RestartPolicy::OnFailure { max_retries: 3 },
..Default::default()
};
```

### Python
```python
box = SimpleBox(
image="python:slim",
restart_policy="on-failure",
max_retries=3
)
```

## Implementation Notes
- Track `restart_count` in BoxState
- Implement backoff strategy (exponential backoff with jitter)
- Add `RestartCount` to BoxMetrics
- Consider `restart_delay` option

## Tasks
- [ ] Add RestartPolicy enum
- [ ] Track restart count in state
- [ ] Implement restart logic with backoff
- [ ] Update Python SDK
- [ ] Add tests
- [ ] Document behavior

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.