Skip to content

[Bug]: Race condition during tool use can cause duplicate message replies #20740

@Arturia169

Description

@Arturia169

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:

  1. The main session agent is given a task that requires a tool call which introduces a slight delay (e.g., sessions_spawn).
  2. The agent sends its initial response message (e.g., announcing the sub-agent dispatch).
  3. Immediately after this message is sent, while the tool call is still in-flight, the user sends a new message to the agent.
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions