diff --git a/src/agentCore.jl b/src/agentCore.jl index 09c4297..399b19a 100644 --- a/src/agentCore.jl +++ b/src/agentCore.jl @@ -224,6 +224,8 @@ function _agentLoop(agent::yiemAgent) followUpMsg = take!(agent.followUpChannel) put!(agent.inputChannel, followUpMsg) end + processingTask = nothing # reset + result = nothing # reset else # _processMessage() done and no followUp message. agent.agentEventSink("_agentLoop 4 agent._state.messages length $(length(agent._state.messages))") result = agent._state.messages[end] @@ -233,7 +235,6 @@ function _agentLoop(agent::yiemAgent) agent.agentEventSink(filtered_content[1].text) end processingTask = nothing # reset - newUserMsg = nothing # reset result = nothing # reset end end @@ -263,6 +264,11 @@ function _agentLoop(agent::yiemAgent) # spawn new _processMessage() if it is not already running. if processingTask === nothing agent.agentEventSink("_agentLoop 5 agent._state.messages length $(length(agent._state.messages))") + # discard all messages in followUpChannel + while isready(agent.followUpChannel) + _ = take!(agent.followUpChannel) + end + # Dispatch message through the processing pipeline processingTask = @spawn _processMessage( processMessageInputCh,