setDynamicConfigCallback
Set a callback that runs on every incoming SWML request, receiving an ephemeral copy of the agent so you can dynamically configure any aspect of it — prompts, parameters, languages, tools, global data, etc. — based on the request’s query parameters, body, or headers.
This is the primary mechanism for multi-tenant or per-caller customization.
The agent argument is an ephemeral copy of the base agent — changes made
inside the callback apply only to the current request and do not persist to the
base agent or affect other requests.
Parameters
cb
A function with the signature
(queryParams: Record<string, string>, bodyParams: Record<string, unknown>, headers: Record<string, string>, agent: AgentBase) => void | Promise<void>.
Use the agent argument to call any configuration method on the ephemeral copy.
Returns
AgentBase — Returns this for method chaining.