Middleware

AgentOS middleware examples for authentication, request context, rate limiting, and custom request handling.

Current v3.0.4 examples:

ExampleDescription
Add rate-limit and request-log middleware to AgentOSCustom Starlette middleware can wrap the FastAPI app returned by AgentOS.get_app().
Observe AgentOS run responses without private response classesThis middleware captures non-streaming JSON bodies and streaming SSE content for POST .../runs requests carrying X-APP-UUID.
JWT authentication from an HTTP-only cookieMount 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 dependenciesExtract trusted claims into request.state, session state, and the dependencies carried by the RunContext passed to agent tools.
Service accounts for machine-to-machine authenticationMint an opaque agno_pat_ token, use its current default scopes, and revoke it.