https://retellai.com/?utm_source=discord&utm_medium=seo logo
Agent not following time-based logic split
# ❓・bug-report
g
Hey guys. I have some agents that are required to determine if it is within business hours before transferring a call to the front office. We have dynamic system variables set up so that the agent is injected with the current time/time zone at the beginning of each call. When presented with the logic split node, the agent is not very accurate in how many times it gets the business hours correct. Sometimes it will transfer after business hours, and it often will not transfer within business hours. See our setup in the images and a call example below. Is there something wrong with the variables or is it the prompting? Call ID: call_ce0ed11ddbc2306334312c43a6a https://cdn.discordapp.com/attachments/1465785079111483464/1465785079765930088/Screenshot_2026-01-27_at_12.03.16_PM.png?ex=697a5e3b&is=69790cbb&hm=6f1dfc73e5af7466db85546873cde7ad4f2781a9befb6fc8573a457c6dfb51cd& https://cdn.discordapp.com/attachments/1465785079111483464/1465785080428363979/Screenshot_2026-01-27_at_12.03.28_PM.png?ex=697a5e3c&is=69790cbc&hm=7dbd31ab889847552eb7298d9e0fe93b313cf898f0efdf22a69e512b82402752& https://cdn.discordapp.com/attachments/1465785079111483464/1465785081279938793/Screenshot_2026-01-27_at_12.03.46_PM.png?ex=697a5e3c&is=69790cbc&hm=963eef464cac98249678354230677be0031d06bdb0172e6f59444d7bdb6a00ec&
s
hi
The closing braces should be on the same line, not a new line. Also, use equation-based checks in the Logic Split (like comparing hours) instead of letting the LLM interpret time, which can be unreliable.
g
@User Oh my goodness I didn't even see the braces issue, I thought that was due to formatting. Can you give me an example of what one of these equation based checks might look like?
s
Click the "+" button on your Logic Split Node
Select "Equation" instead of "Prompt"
like this {{current_hour}} >= 8 AND {{current_hour}} < 17 {{is_business_hours}} == "true" {{user_location}} == "New York"
g
Thank you! I will give this a test. Also, for some reason when I ask the agent what time it is, it refuses to tell me and says that "it doesnt have access to that issue" even though the variables are set. Why could this be?
s
may be due to braces issue
g
are there any addition variables we need to inject for {{is_business_hours}} / {{user_location}}?
Or for all of them i guess, or does the system already know {{current_hour} etc. when we inject the time zone/current time
s
the above variable i show is just for example its not a default variable. you need to inject custom dynamic variables.
or build in variable
g
Ok sounds good. Thank you for your help!
s
no problem
g
The agent still refuses to give me the time after braces fix. There is also no prompting that would restrict this? How can I confirm the agent is correctly receiving current time?
s
you can test it on maunal chat
also told him in the agent prompt that "you have access to the current time: {{current_time}}. You can tell the user the current time if asked."
g
I will add that prompt and report back
s
ok
g
That worked! Thank you again
n
This is a super helpful thread, thank you! I am wondering though, is there any way to do this in a prompt based agent? I find that the prompt based agents have a terrible time with determining whether or not it is inside business hours and I usually have to write a custom function to call an external server to make the decision programmatically. It would be super nice if there's a better way like this though. Another interim fix I have is that I send it to the conversation flow first and then to two different agents depending on the decision made by the logic split demonstrated in this thread.