os_restart_api
Safely restart the AI Team OS FastAPI process after backend code changes. Guards against busy agents, port drift, and spawning before the old process exits, with optional force or dry-run checks.
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. | |
| dry_run | No | Only preflight imports and return the startup plan, without shutting down, spawning, or updating shared runtime files. | |
| source_root | No | Explicit ai-team-os repository root to import and start. Empty preserves the current environment. Restore by explicitly passing the original repository root through this same flow. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||