Two issues caused duplicate messages to be sent to users: 1. System messages (from subagent): processSystemMessage set SendResponse:true, causing runAgentLoop to publish outbound. Then Run() also published outbound using the returned response string, resulting in two identical messages. Fix: processSystemMessage now returns empty string since runAgentLoop already handles the send. 2. Message tool double-send: When LLM called the "message" tool during processing, it published outbound immediately. Then Run() published the final response again. Fix: Track whether MessageTool sent a message in the current round (sentInRound flag, reset on each SetContext call). Run() checks HasSentInRound() before publishing to avoid duplicates.
2.3 KiB
2.3 KiB