-
-
Notifications
You must be signed in to change notification settings - Fork 69.6k
[Bug]: Race condition during tool use can cause duplicate message replies #20740
Description
We've observed a potential race condition where the agent sends a duplicate of its previous message. This seems to occur when a new user message is received while the agent is actively processing a tool call (specifically sessions_spawn).
Steps to Reproduce:
- The main session agent is given a task that requires a tool call which introduces a slight delay (e.g.,
sessions_spawn). - The agent sends its initial response message (e.g., announcing the sub-agent dispatch).
- Immediately after this message is sent, while the tool call is still in-flight, the user sends a new message to the agent.
- The timing appears to be critical, creating a race condition between the ongoing tool processing and the handling of the new inbound message.
Expected Behavior:
The agent should process the new user message normally (either after the tool call completes or by correctly queuing it), without sending any duplicate messages.
Actual Behavior:
The agent re-sends its previous response (the message sent just before initiating the tool call). This results in a confusing duplicate message appearing in the chat interface. A screenshot of this behavior has been captured.
Environment:
- OpenClaw Version:
2026.2.17 - Platform:
Linux (Debian) - Node.js Version:
v24.13.1 - Channel:
Telegram - Agent Model in Use:
gemini_official/gemini-2.5-pro
Additional Context:
No specific errors were observed in the gateway logs when this occurred. The issue seems to be related to the core message handling logic under concurrent load.