set_dynamic_config_callback
set_dynamic_config_callback
Set a callback function that runs on every incoming request, receiving an ephemeral copy of the agent so you can dynamically configure any aspect of it — skills, 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.
This call replaces every per-call configuration registered before it, including
callbacks added with add_per_call_config(), without warning.
The agent still renders valid SWML, but whatever the discarded callbacks configured is
absent, so a subclass that calls it drops what its base class registered. Callbacks
added with add_per_call_config() afterward run after this one. To register several
callbacks that run in order, use add_per_call_config().
The agent argument passed to the callback is an ephemeral copy of the original
agent. Changes made inside the callback apply only to the current request and do not
persist across calls.
Parameters
callback
A function with the signature (query_params, body_params, headers, agent).
Use the agent argument to call any configuration method:
agent.add_skill(...)agent.add_language(...)agent.prompt_add_section(...)agent.set_params(...)agent.set_global_data(...)agent.define_tool(...)
Returns
AgentBase — Returns self for method chaining.