https://retellai.com/?utm_source=discord&utm_medium=seo logo
can you help:Dear @Bing Wu, @evieCan you help us d...
# ❓・ai-evy-support
o
@AI Evy can you help: Dear @Bing Wu, @evie Can you help us debug an issue with tool call issue with agent transfer. This seems to be happening with agent transfer node. We put an API token dynamic variable at start of call with a webhook, and we noticed that dynamic variables is not preserved in swapped agent, can you help us figure out how to solve it: Our setup: Have one simple conversation flow to start conversation IVR thing, and route to smart PROMPT Agent to do things We set some metadata at beggining of call with webhooks (API TOKEN) All tool calls put in header an API TOKEN Param. Agents work when we attach it manually but after agent_swap tool call, new agent don't have access to old webhook values. EXample agent: call_e97053397c15b4dcad078b4c165 - problematic call agent_1ecaf11b997cecf17bbdeba6bd - agent IVR simple agent_5aa3755f68195d2d3f56ab7c4e - smart IVR which got transfer. Can you help figure it out?
a
Thanks for tagging me @ozeron1348. I'll look through relevant sources and get back to you shortly.
### Answer I understand your issue with dynamic variables not persisting after an agent transfer. Based on the documentation, dynamic variables set at the beginning of a call are specific to that call instance, not automatically transferred between agents. [(1) ]() [(2) ]() The Issue: When you set
retell_llm_dynamic_variables
via webhook at call start, those variables are associated with the initial agent. [(1) ]() [(3) ]() When you perform an agent transfer/swap, the new agent doesn't automatically inherit these variables. [(2) ]() Solution: You need to use the Update Call API to override or add dynamic variables during the call, including after agent transfers. Use the
override_dynamic_variables
parameter in the Update Call API:
Copy code
json
{  
  "override_dynamic_variables": {
    "api_token": "your_token_value"
  }
}
Key Points: -
override_dynamic_variables
allows you to override or add dynamic variables during an active call - Setting this will override or add the dynamic variables set in the agent during the call - You only need to set the delta where you want to override, not the entire dynamic variables object - All dynamic variable values must be strings [(1) ]() [(4) ]() Implementation Approach: 1. When your agent transfer tool is called, also trigger an Update Call API request 2. Pass the necessary dynamic variables (like your API token) in the
override_dynamic_variables
field 3. This ensures the transferred agent has access to the required variables This should resolve your issue with tool calls not having access to the API token after agent transfer. **
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Update Call](https://docs.retellai.com/api-references/update-call) [[3] Create Phone Call](https://docs.retellai.com/api-references/create-phone-call) [[4] Dynamic Variables via inbound webhook break if non-string values are sent](https://discord.com/channels/1186424376300679209/1420429628979282011) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.