Asterisk AGI starts before call completely connected

I have an Asterisk app that receives calls via IAX and hands it off to an AGI written in Perl. It immediatly greets inbound callers by saying something like “Hello, welcome to blah blah blah…”. The problem is that the the AGI seems to start before the call is completely connected. THe user usually misses the first few words of the introductory prompt. I have worked around the problem in the past by putting in a sleep(1) in the Perl script, but I hate the unnecessary delay. It only happens in production when the call is coming in from It never happens when I connect via IDEFISK in either production or test environments. What can I do to fix this?

Here are the important parts of the Asterisk app:
iax.conf ----------
extensions.conf --------
exten => s,1,Set(TIMEOUT(absolute)=3900)
exten => s,2,AGI(
exten => s,3,Hangup() AGI App -------------------
It gets the AGI parameters, tells Asterisk to ANSWER, and almost immediately does a STREAM FILE.