mount
Mount an extra router or ASGI app alongside this agent’s own routes. Use it
instead of get_app() followed by include_router() or mount()
by hand, which fails silently in three ways:
- Anything mounted after
serve()starts is lost, becauseserve()builds a fresh app when none exists. This method materializes the app first so a laterserve()reuses it. - The agent registers a catch-all route, and FastAPI matches routes in registration order, so any route added afterwards is shadowed and never runs. This method moves the catch-all back to the end.
- The app that
get_app()builds answers the agent’s bare route (no trailing slash) with204instead of SWML. This method re-registers that route, so the URL the platform fetches keeps working.
Parameters
app_or_router
A FastAPI APIRouter, included at prefix, or any other ASGI app such as
StaticFiles, mounted at prefix.
prefix
Path prefix, without a trailing slash. Keyword-only.
name
Mount name. Used only for ASGI apps. Keyword-only.
Returns
AgentBase — Returns self for method chaining.
Example
See ChatGateway for what the mounted router serves.