| Example | Description |
|---|---|
| Add rate-limit and request-log middleware to AgentOS | Custom Starlette middleware can wrap the FastAPI app returned by AgentOS.get_app(). |
| Observe AgentOS run responses without private response classes | This middleware captures non-streaming JSON bodies and streaming SSE content for POST .../runs requests carrying X-APP-UUID. |
| JWT authentication from an HTTP-only cookie | Mount login/logout routes on the base FastAPI app, read JWTs from a secure cookie, and enforce AgentOS scopes normally. |
| JWT claims into request state and agent dependencies | Extract trusted claims into request.state, session state, and the dependencies carried by the RunContext passed to agent tools. |
| Service accounts for machine-to-machine authentication | Mint an opaque agno_pat_ token, use its current default scopes, and revoke it. |
Middleware
Middleware
AgentOS middleware examples for authentication, request context, rate limiting, and custom request handling.
Current v3.0.4 examples: