Description:
There is an issue with inbound SMS agent handling in Retell AI where the previous agent session continues even after the agent is removed or reassigned.
Steps to Reproduce:
Configure an inbound SMS number.
Assign an agent (Agent A).
Start an SMS conversation.
Change the agent (Agent B) or remove the agent.
Send another inbound SMS.
Expected Behavior:
The previous agent session should terminate immediately.
The system should either:
Use the newly assigned agent, or
Stop responding if no agent is assigned.
Actual Behavior:
The previous agent (Agent A) continues handling messages.
Session/context does not reset after agent removal or change.
Critical Observation:
The issue persists until one of the following actions is performed:
Sending an outbound SMS, or
Changing the inbound SMS number
After either of these actions, the system resets and starts behaving correctly.
Impact:
Users receive responses from outdated agent configurations.
Breaks expected real-time agent switching behavior.
Can lead to incorrect or unintended communication.
Likely Root Cause (Stronger Hypothesis):
Session or conversation state is being cached and not invalidated on agent update/removal.
Outbound SMS or number change likely triggers:
Session refresh
Cache invalidation
Rebinding of agent configuration
Suggested Fix:
Force session invalidation when:
Agent assignment is updated
Agent is removed
Ensure inbound message handling:
Always fetches the latest agent configuration
Does not rely on stale session cache
Environment:
Retell AI – SMS (Inbound Flow)
Issue reproducible consistently