Issue: Inconsistent business-hours detection near midnight boundary

Our agent uses a dynamic variable for the current time in New York ex: {{current_time_America/New_York}}. The system prompt tells the LLM to compare this against our hours (open 2 PM–2 AM daily) to decide OPEN or CLOSED.

Problem: This works most of the time, but is inconsistent specifically around the 2 AM boundary — on some calls it correctly says CLOSED, on other calls at roughly the same time it says OPEN. Same prompt, same time of night, different result.

Our understanding: the LLM is doing the AM/PM comparison itself each time as part of its reasoning, rather than following a fixed calculation, so it’s not deterministic.

Question: Is there a recommended, native way in Retell to do a reliable open/closed time-window check, rather than relying on the LLM to compare the dynamic variable against a schedule in the prompt?

Hey @lahariyalavarthy Could you please share your Agent ID and this Call ID? This will help us investigate the issue further.

Thank You

Hi Shah,
Thanks for replying.

Here is the agent ID: agent_9ea157742139b663dd855932ef
Here are few call id’s:
call_e2626b305977211f34d3354c531
call_8b799e2bbc36196fda654567a38
call_38ebc4dd9b8b483333f03fa79c8

Hey @lahariyalavarthy Checking it with the team.

Hello @lahariyalavarthy The {{current_time_America/New_York}} dynamic variable does expand to the right timezone-aware string, but everything after that (parsing “12:20 AM” and deciding whether it sits inside a 2 PM to 2 AM window that crosses midnight) is the LLM reasoning in free text, and that isn’t deterministic near the boundary. That’s exactly why you see the same-minute flip in your call sample.

The reliable pattern is to compute OPEN or CLOSED outside the LLM and pass the answer in as a variable. Two native options that fit your setup:

Option 1: Pre-call inbound webhook (recommended for your single-prompt agent). In the workspace inbound webhook, compute open_status (“OPEN” or “CLOSED”) in your own code using the current time in America/New_York, then return it under retell_llm_dynamic_variables. Your prompt then reads {{open_status}} directly instead of doing the math, so the LLM only needs to state the answer. Docs on dynamic variables and where they’re supported: Dynamic variables: personalize Retell agent calls - Retell AI

Option 2: Code Tool at the start of the call. Add a Code Tool to the agent and instruct it to call the tool on the very first turn to set open_status. The tool receives the dynamic variables via the dv object and returns fields you can store as new dynamic variables. This keeps everything inside Retell (no webhook infra needed), with the caveat that the LLM has to invoke the tool early, so gating the greeting on it helps. Docs: Run JavaScript in Retell agents with Code Tool
If you’re open to it, migrating this agent to a Conversation Flow lets you add a Code Node at the entry point that runs unconditionally before any LLM turn, which is the most deterministic version of Option 2. Docs: Run JavaScript in a Retell conversation flow with Code node

Whichever path you pick, rewrite the prompt so it stops comparing times and instead says something like: “If {{open_status}} is CLOSED, tell the caller we’re closed and offer to take a message; if OPEN, greet normally.” That removes the AM/PM reasoning entirely, which is what’s flipping.

Thank You

Thanks for the input Shah

I will try this and let you know