> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # setDynamicConfigCallback > Set a callback for per-request dynamic agent configuration. [ref-agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base 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. > **Note** > > 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`** `DynamicConfigCallback` — required A function with the signature `(queryParams: Record, bodyParams: Record, headers: Record, agent: AgentBase) => void | Promise`. Use the `agent` argument to call any configuration method on the ephemeral copy. --- ## **Returns** [`AgentBase`][ref-agentbase] -- Returns `this` for method chaining. ## **Example** ```typescript {6} import { AgentBase } from '@signalwire/sdk'; const agent = new AgentBase({ name: 'assistant', route: '/assistant' }); agent.setPromptText('You are a helpful assistant.'); agent.setDynamicConfigCallback(async (queryParams, bodyParams, headers, agentCopy) => { const tier = queryParams.tier ?? 'standard'; if (tier === 'premium') { agentCopy.setParams({ end_of_speech_timeout: 500 }); } agentCopy.setGlobalData({ tier }); }); await agent.serve(); ``` > Set a callback for per-request dynamic agent configuration.