Supervisor Restart Strategies
Supervisors monitor child agents and restart them when they fail. The restart strategy determines how failures are handled.
Available Strategies
one-for-one
When one agent fails, only that agent is restarted. Other agents continue running.
Before: [Agent A ✓] [Agent B ✗] [Agent C ✓]
After: [Agent A ✓] [Agent B ✓] [Agent C ✓]
↑
restarted
Use when: Agents are independent and don't share state.
naos supervisor create main --strategy one-for-one
one-for-all
When one agent fails, ALL agents are restarted.
Before: [Agent A ✓] [Agent B ✗] [Agent C ✓]
After: [Agent A ✓] [Agent B ✓] [Agent C ✓]
↑ ↑ ↑
restarted restarted restarted
Use when: Agents share state and must be consistent.
naos supervisor create main --strategy one-for-all
rest-for-one
When one agent fails, that agent and all agents started AFTER it are restarted.
Start order: A → B → C → D
B fails:
Before: [Agent A ✓] [Agent B ✗] [Agent C ✓] [Agent D ✓]
After: [Agent A ✓] [Agent B ✓] [Agent C ✓] [Agent D ✓]
↑ ↑ ↑
restarted restarted restarted
Use when: Later agents depend on earlier agents.
naos supervisor create main --strategy rest-for-one
Choosing a Strategy
| Scenario | Strategy |
|---|---|
| Independent workers | one-for-one |
| Shared database connection | one-for-all |
| Pipeline with dependencies | rest-for-one |
| Default choice | one-for-one |