---
title: "Max Restarts"
description: "Prevent infinite restart loops by limiting how many times a supervisor will restart a failing agent. The supervisor counts restarts within the restart window: The restart window determines the time period for counting re"
resource: https://www.aiagents.nexus/docs/manual/supervisors/max-restarts
generated: { by: "process:nexus-agent-assets", at: 2026-09-07T09:13:03Z }
status: stable
---

# Max Restarts

Prevent infinite restart loops by limiting how many times a supervisor will restart a failing agent.

## Configuration

```bash
naos supervisor create main --strategy one-for-one --max-restarts 3
```

```yaml
supervisors:
  main:
    strategy: one-for-one
    maxRestarts: 3
    restartWindow: 60    # seconds
```

## How It Works

The supervisor counts restarts within the restart window:

```
Time 0s:  Agent fails → Restart 1/3
Time 10s: Agent fails → Restart 2/3
Time 20s: Agent fails → Restart 3/3 (max reached)
Time 25s: Agent fails → NOT restarted, marked as failed
```

## Restart Window

The restart window determines the time period for counting restarts. After the window expires, the count resets.

```
Window: 60 seconds, Max: 3

Time 0s:  Agent fails → Restart 1/3
Time 10s: Agent fails → Restart 2/3
Time 70s: Agent fails → Restart 1/3 (window reset!)
```

## Defaults

| Setting | Default |
|---------|---------|
| maxRestarts | 3 |
| restartWindow | 60 seconds |

## What Happens at Max

When max restarts is reached:
1. The agent is marked as `failed`
2. The supervisor logs the event
3. The agent is NOT restarted again
4. An audit entry is created

```bash
naos supervisor status main

# Children:
#   worker-1   ● running    0 restarts
#   worker-2   ✗ failed     3 restarts (max reached)
```
