Skip to content

A2A sessions_send: target agent can call sessions_send back, causing duplicate messages #39476

Description

@SYRS-AI

Summary

When Agent A calls sessions_send to Agent B, Agent B can use sessions_send to call back to Agent A with its response. This causes duplicate messages in the requester's channel:

  1. The original sessions_send tool returns primaryReply → Agent A posts it
  2. Agent B independently calls sessions_send back to Agent A → Agent A posts it again (different wording, same content)

Additionally, the ping-pong mechanism re-injects the primaryReply into the requester's session, which can also trigger a second post.

Steps to Reproduce

  1. Agent A (e.g. on Discord) calls sessions_send(agentId: "agentB", message: "...")
  2. Agent B processes the request and generates a response
  3. Agent B sees requesterSessionKey in its A2A context and decides to call sessions_send back to Agent A with a detailed report
  4. Agent A receives both: (a) the tool return value, and (b) the reverse sessions_send message
  5. Both get posted to Discord → user sees duplicate content

Expected Behavior

The target agent should not be able to call sessions_send back to the requester during A2A processing. The A2A flow already handles result delivery via the tool return value.

Proposed Fix

Two options (not mutually exclusive):

Option A: Disable sessions_send for target during A2A processing (recommended)

When runSessionsSendA2AFlow invokes runAgentStep on the target, temporarily remove or disable the sessions_send tool from the target's available tools. This is a code-level guard that's 100% reliable.

Option B: Don't expose requesterSessionKey in A2A context

In buildAgentToAgentMessageContext, stop including params.requesterSessionKey. The target agent doesn't need to know the requester's session key — it just needs to respond normally in its own session. Removing the key eliminates the most direct path for reverse calls (though the agent could still use agentId).

Current Workaround

We added two dist patches:

  • Skip entire A2A flow (ping-pong + announce) when roundOneReply exists and requester is on a non-webchat channel — prevents ping-pong duplication
  • Prompt injection in buildAgentToAgentMessageContext adding "Do NOT use sessions_send to reply" — ~90% effective at preventing reverse calls

Environment

  • openclaw version: latest (npm global install, as of 2026-03-08)
  • Platform: macOS ARM64
  • Multiple agents on Discord with cross-channel A2A communication

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions