Stateless design: Existing delegation tokens remain valid until they expire, even after suspension or revocation. Token validation only checks the JWT signature and expiry, not the agent's current status.
Step-by-Step
1
Suspend an Agent
Suspension is reversible — use it when an agent needs temporary restriction:
2
Attempt Delegation to Suspended Agent
Delegating to a suspended agent fails immediately:
3
Reactivate an Agent
Reactivation is done at the provider level, not through the gateway:
Reactivation is intentionally not on the IAMGateway to require explicit provider-level access. This prevents accidental reactivation through the standard API.
4
Revoke an Agent (Permanent)
Revocation is the kill switch — permanent and irreversible:
After revocation:
No new delegations can be created
The agent cannot be reactivated
The revoked_at timestamp is recorded
5
List Agents
List agents in an organization, optionally including revoked ones:
You've learned how to manage the full agent lifecycle — suspend, reactivate, revoke, and list agents!
Existing tokens remain valid until they expire. If you need immediate invalidation, use short expires_in_seconds values in your delegation scopes as a best practice. For truly critical scenarios, rotate the secret_key to invalidate all tokens (this affects all agents and users).
Complete Example
Create agent_lifecycle.py:
Run it:
Expected output:
Common Pitfalls
Pitfall
Solution
Revoking when suspend is enough
Revocation is permanent. Use suspend_agent first to investigate.
Existing tokens still valid
Tokens are stateless JWTs. Use short expires_in_seconds as a best practice.
Reactivate is provider-only
reactivate_agent is on the provider, not the gateway. This is by design.
Missing organization_id
Pass organization_id to scope operations to the correct organization.
Revoking affects all chains
All delegation chains involving the revoked agent will fail on new delegations.
Next Steps
Register Agent — Register new agents to replace revoked ones
Scope & Budget — Use short expiry times for defense in depth
Result Pattern — Handle errors from lifecycle operations