https://retellai.com/?utm_source=discord&utm_medium=seo logo
Our Retell AI agent is incorrectly caching and reu...
# ❓・ai-evy-support
p
Our Retell AI agent is incorrectly caching and reusing customer authentication data (specifically the custnum variable) between completely different phone calls from different customers. This is causing Customer B's verification attempts to be checked against Customer A's account, creating a severe security vulnerability. Expected Behavior: Each phone call should be completely isolated When Customer A calls and authenticates with custnum "12345", this should be forgotten when the call ends When Customer B calls next, they should authenticate with their own custnum (e.g., "67890") Variables should NEVER persist between different callers Actual Behavior: Customer A (Rosa) calls and authenticates with custnum "222923" Call ends Customer B calls from a different phone number Agent incorrectly sends custnum "222923" (Rosa's) for Customer B's verification Customer B provides their postal code (e.g., "N0B1M0") Verification fails because it's checking Customer B's postal against Rosa's account Evidence from Our Logs: Execution 1 (22:48:54): custnum: "222923", postal: "N2K4M5" - FAILED (wrong postal for Rosa) Execution 2 (22:50:43): custnum: "222923", postal: "N2K4L7" - SUCCESS (Rosa's correct postal) Execution 3 (22:52:02): custnum: "222923", postal: "N2K4L7" - SUCCESS (Rosa's correct postal) Execution 4 (00:58:31): custnum: "222923", postal: "N0B1M0" - FAILED (different customer, but using Rosa's custnum!) All verification attempts are using the same custnum "222923" regardless of who is calling. Our Configuration: Agent ID: [Your Agent ID] Webhook endpoints: /webhook/authenticate-customer - Returns custnum for current caller /webhook/verify-identity - Receives custnum from agent for verification @AI Evy
a
Thanks for tagging me @peterthehammer_05753. I'll look through relevant sources and get back to you shortly.
### Answer The issue you're describing with variable persistence between different calls is a serious security concern. Based on the available sources, here are the key points to address this: Each call in Retell AI should be completely isolated by design [(1) ]() . Webhooks are triggered for individual call events, and the webhook payload contains the event type and the specific call object for that particular call . For proper call isolation, you should leverage the dynamic variables system. When initiating calls, you can pass call-specific data using
retell_llm_dynamic_variables
[(2) ]() . This ensures each call has its own isolated context.
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const callResponse = await client.call.update('call_a4441234567890777c4a4a123e6', {
 metadata: { customer_id: 'cust_123', notes: 'Follow-up required' },
 opt_out_sensitive_data_storage: true,
}) ;
[(3) ]() The webhook system is designed to include everything you pass into the parameter for each specific call [(2) ]() . This means your authentication data should be call-specific and not persist across different calls. For your webhook endpoints, ensure that: 1. Your
/webhook/authenticate-customer
endpoint generates fresh authentication data for each new call 2. Your
/webhook/verify-identity
endpoint only uses data from the current call's context 3. You're not storing state globally that could leak between calls The webhook verification process should be implemented to ensure authenticity [(4) ]() :
Copy code
javascript
import { Retell } from "retell-sdk";
import express, { Request, Response } from "express";
const app = express() ;
app.use(express.json() ) ;
app.post("/webhook", (req: Request, res: Response) => {
 if (
 !Retell.verify(
 JSON.stringify(req.body) ,
 process.env.RETELL_API_KEY,
 req.headers["x-retell-signature"] as string,
 )
 ) {
 console.error("Invalid signature") ;
 return;
 }
 const {event, call} = req.body;
 // process the webhook
 // Acknowledge the receipt of the event
 res.status(204) .send() ;
}) ;
If the problem persists, I recommend contacting Retell AI support at [Contact Sales]() or checking [) for additional troubleshooting resources.
​ To learn more, see the sources I considered: [[1] Webhook Overview](https://docs.retellai.com/features/webhook-overview) [[2] Discord message from @medivoice_63089 on 2025-02-05](https://discord.com/channels/1186424376300679209/1294891368505937952/1336750733042909245) [[3] Update Call](https://docs.retellai.com/api-references/update-call) [[4] Secure the webhook](https://docs.retellai.com/features/secure-webhook) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
p
@AI Evy Thank you for your response. We've verified that our webhooks are completely stateless: Our webhooks do NOT store any global state Each webhook execution is independent We're using the custnum directly from $json.body.custnum The Real Issue We've Discovered: The problem is NOT in our webhook implementation. The issue is that the Retell agent is not calling authenticate_customer for new callers. Evidence: Test Scenario: Call 1: Rosa calls, authenticate_customer IS called, returns custnum "222923" Call 2: Different person calls PROBLEM: authenticate_customer is NOT called for Call 2 Agent uses Rosa's custnum "222923" from memory for Call 2's verify_identity What's Actually Happening: Call 1 (Rosa): 1. authenticate_customer called → returns custnum "222923" 2. verify_identity called with custnum "222923" ✓ Call 2 (Different Person): 1. authenticate_customer NOT CALLED (This is the bug!) 2. verify_identity called with custnum "222923" (Rosa's cached custnum) Our Webhook Logs Show: Multiple verify_identity calls with custnum "222923" Only ONE authenticate_customer call that returned "222923" This proves the agent is reusing the custnum without re-authenticating The Core Issue: The agent is caching the custnum variable between calls and not calling authenticate_customer for new callers. What We Need: Force the agent to call authenticate_customer at the start of EVERY new call Prevent the agent from caching ANY variables between different callers Ensure each call_id has completely isolated context Questions: Why is the agent not calling authenticate_customer for new calls? Is there a setting to force function calls at the start of each call? How can we prevent the agent from caching variables between calls? Our webhooks are stateless. The issue is the agent's behavior. Please escalate to engineering.
a
Thanks for the follow-up, @peterthehammer_05753. I'll get back to you soon.
### Answer Based on the available documentation, I can see the issue you're describing is related to call isolation and function calling behavior. Here's what the documentation shows about call management: Each call should have its own unique
call_id
that serves as the identifier [(1) ]() . When you create or register phone calls, they receive distinct identifiers:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const phoneCallResponse = await client.call.registerPhoneCall({
 agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
}) ;
[(2) ]() The call object includes metadata and dynamic variables that should be call-specific [(3) ]() [(1) ]() :
Copy code
javascript
const callResponse = await client.call.update('call_a4441234567890777c4a4a123e6', {
 metadata: { customer_id: 'cust_123', notes: 'Follow-up required' },
 opt_out_sensitive_data_storage: true,
}) ;
[(3) ]() Each call response includes
retell_llm_dynamic_variables
and
collected_dynamic_variables
that should be isolated per call [(3) ]() [(1) ]() . The documentation shows these are part of the individual call object structure. However, the available sources don't contain specific information about: - Function calling behavior at call initiation - Settings to force specific function calls at the start of each call - Agent memory management between calls - How to prevent variable caching across different calls Since this appears to be an agent behavior issue related to function calling and memory management that isn't covered in the available API documentation, I recommend contacting Retell AI support directly: - Visit [Contact Sales]() - Visit [) This issue requires engineering investigation as it involves the core agent behavior and function calling logic, which isn't detailed in the API reference documentation.
​ To learn more, see the sources I considered: [[1] Get Call](https://docs.retellai.com/api-references/get-call) [[2] Register Phone Call](https://docs.retellai.com/api-references/register-phone-call) [[3] Update Call](https://docs.retellai.com/api-references/update-call) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.