on_swml_request
on_swml_request
Customization point called during SWML rendering, before the document is returned to the caller. Override this method in a subclass to inspect request data and return modifications to apply to the SWML document.
The default implementation checks for a
set_dynamic_config_callback()
and, if one is registered, returns an internal marker that triggers ephemeral
agent cloning. For most per-request customization,
set_dynamic_config_callback()
is the simpler approach.
This method is called during SWML rendering by the internal request handler. It
is not an override of SWMLService.on_request() — it is a separate hook that
adds support for dynamic configuration and ephemeral agent copies.
Parameters
request_data
Parsed POST body from the incoming request, if available.
callback_path
The path segment that triggered this request.
request
The FastAPI Request object, providing access to query parameters, headers,
and other HTTP metadata.
Returns
Optional[dict] — A dictionary of modifications to apply to the SWML document,
or None for no modifications. The keys and structure depend on the rendering
pipeline.
Example
For most per-request customization scenarios, prefer
set_dynamic_config_callback()
which provides a higher-level interface with access to query params, body, headers,
and the agent instance.