Agents still busy after transferring calls

Asterisk 11.1.0 I use the code below to add agents:

exten => 220,1,Answer() exten => 220,n,VMAuthenticate(@agent) exten => 220,n,AddQueueMember(Queue1,Local/${AUTH_MAILBOX}@to_agents/n,,,,Local/${AUTH_MAILBOX}@to_agents) exten => 220,n,AddQueueMember(Queue2,Local/${AUTH_MAILBOX}@to_agents/n,,,,Local/${AUTH_MAILBOX}@to_agents) exten => 220,n,Read(AGENT_SIP,agent-newlocation) exten => 220,n,Set(DB(agent_sip/${AUTH_MAILBOX})=${AGENT_SIP}) exten => 220,n,Playback(agent-loginok) exten => 220,n,Playback(goodbye) exten => 220,n,Hangup
If an agent receives a call and then transfers it, that agent is still seen as in use until the transferred call ends. Am I perhaps defining the stateinterface incorrectly?

More info - transfers are done by hitting ## and then, for example:

exten => 322,1,Dial(SIP/phone1,25,tT)
exten => 322,2,Voicemail(621,u)
exten => 322,3,hangup

The answer will depend on the options on the Dial within the local channel. If that allows transfers, the local channel will still exist, after the transfer.

Even if not, I’m not convinced that the call will have dropped far enough back in the queue application for it to sense that there has been a change.

Hi - I’m not sure this is what you’re asking, but this is how calls get to the queue:

exten => s,n,Answer exten => s,n,Ringing exten => s,n,Wait(2) exten => s,n,Playback(pls_wait_rep) exten => s,n,Playback(this-call-may-be-monitored-or-recorded) exten => s,n,Set(DIRNAME=${CALLERID(num)}/${STRFTIME(${EPOCH},,%Y%m/%d)}) exten => s,n,Set(FILENAME=${DIRNAME}/${STRFTIME(${EPOCH},,%H%M%S)}-${EXTEN:2}) exten => s,n,System(/bin/mkdir -p /var/spool/asterisk/monitor/${DIRNAME}) exten => s,n,MixMonitor(${FILENAME}.gsm) exten => s,n,Queue(Queue1,tr,,,15)

How do they get from queue to agent?

For example:

exten => 322,1,Set(GROUP(${EXTEN})=incoming)
exten => 322,n,noop( ${GROUP_COUNT(incoming@${EXTEN})} )
exten => 322,n,GotoIf($[${GROUP_COUNT(incoming@${EXTEN})} > 1 ]?333)
exten => 322,n,Dial(SIP/phone,25,tT)
exten => 322,n,Hangup

will act on the Local channel, so the call will not have changed state as far as the queue application is concerned.

OK thanks - I guess I’m trying something that won’t work. Any advice for a solution, maybe changing how agents are defined?