tai42_app handle and depend on tai42-contract only.
These are server-side code plugins — they run in the Python process. To extend the browser workbench instead — contribute pages, tool panels, or sidebar nav entries to the Studio shell — see Author a Studio plugin.
Routes
Add an HTTP route with@tai42_app.http.custom_route. It registers a Starlette handler and its self-describing OpenAPI metadata in one call — summary, tags, and response_model are required so the route describes itself to the API reference.
examples/code_plugins/routes.py
routers_modules. A packaged plugin can also ship this route as a router item in its tai-plugin.yml, so the marketplace installer wires it in.
Middleware
Add ASGI middleware with@tai42_app.http.middleware, which registers the middleware onto the app’s stack.
manifest.yml
middleware item in its tai-plugin.yml.
Lifecycle handlers
Run code at process startup, shutdown, or after an in-place reload. Register a handler with@tai42_app.lifecycle.on_startup, on_shutdown, or on_reload. An on_reload handler re-runs after every reload — use it for dynamic loaders that on_startup ran once.
examples/code_plugins/lifecycle.py
lifecycle_modules. This is also how import-only registrations — a webhook verifier, a connector provider — reach the process.
Pooled clients
A pooled client shares one connection per event loop across tool calls. Subclass the kit’sPooledClient (which implements the BaseClient contract), then open it through tai42_app.clients.client_ctx from inside a tool, route, or lifecycle handler. The context manager yields a connected client, pooled per loop and connection params (or one-shot with fresh=True).
examples/code_plugins/pooled_client.py
client_ctx at call time.
See also
- The manifest — the
routers_modules,middlewares_modules, andlifecycle_modulessections. - Live operations — the reload an
on_reloadhandler responds to. - HTTP API reference — the routes a
custom_routecontributes. - Python SDK reference — the
tai42_app.http,tai42_app.lifecycle, andtai42_app.clientssurfaces.

