unregister_agent
Remove an agent from the relay registry and delete its associated messages and tasks for clean shutdown, role rotation, or recovery. Idempotent: unregistering a missing name returns removed:false.
Instructions
Remove an agent row so the relay reflects true presence after a clean shutdown.
When to use: terminal exit, role rotation, or one half of the recovery flow when reusing a name after revoke_token set the row to revoked. For graceful working-state announcements without removing the row, use set_status with offline instead.
Behavior: deletes the agent row + all messages and tasks the agent was the from/to of (cascade). Idempotent, unregistering a name that does not exist returns removed:false instead of an error. Auth: requires the agent's own token, OR for admin removals an authenticated agent with manage_others capability.
Returns: { success: true, name, removed: boolean, note }. removed=false indicates the name was already absent (idempotent no-op) and is NOT an error.
Errors: AUTH_FAILED (token missing or wrong owner), INVALID_INPUT.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Agent name to unregister | |
| agent_token | No | Your agent token (from register_agent response). Optional here — also resolvable from RELAY_AGENT_TOKEN env or X-Agent-Token header. |