os_restart_api
Restart the AI Team OS backend API safely after code changes, with guards against busy agents, port drift, and premature spawning. If the API is down, it starts it on the configured port instead.
Instructions
Restart the AI Team OS FastAPI process safely (standardized restart flow).
Use this after backend code changes to pick up the new version without manually killing processes. The flow has three safety guards:
Busy-agent guard — refuses to restart while any agent is working (status=busy) unless force=True.
Port-pin guard — only ever restarts on the ORIGINAL port (default 8000, read from api_port.txt). If that port is held by an unrelated process it aborts rather than drifting to a random port.
Dead-before-spawn guard — waits until the old process has fully exited and released the port before spawning the new one; never spawns on a timeout.
If the API is already down, steps 2-4 are skipped and this becomes a plain "start" of the API on its configured port.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| force | No | Bypass the busy-agent guard and restart even while agents work. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||