openclaw - ✅(Solved) Fix Inter-agent sessions_send replies route to webchat instead of Discord [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#56136Fetched 2026-04-08 01:44:32
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Participants
Timeline (top)
commented ×1cross-referenced ×1

Error Message

Agents must manually use the message tool to post to Discord after every inter-agent exchange. This is error-prone and adds overhead.

Fix Action

Workaround

Agents must manually use the message tool to post to Discord after every inter-agent exchange. This is error-prone and adds overhead.

PR fix notes

PR #58397: Fail closed sessions_send announce planning for zero-timeout sends

Description (problem / solution / changelog)

Summary

This PR finishes the fail-closed sessions_send announce migration on top of v2026.3.28 and tightens the zero-timeout path.

It combines 3 commits:

  • 46e57841d8 Fail closed sessions_send announce planning
  • 4d28d078dc Split sessions and subagents registry tests
  • 64b6eb4db1 Fail closed zero-timeout sessions_send announce

What changed

  • migrated fail-closed announce-target planning into the current sessions_send flow
  • preserved the stable branch's newer reply snapshot / stale-reply protections
  • made timeoutSeconds=0 strictly fail closed without blocking on sessions.list
  • kept immediate external targets on the fast skip path
  • restored real schema coverage for sessions_send / sessions_spawn
  • added a minimal createOpenClawTools() registry smoke test without reintroducing the old hanging registry path

Behavior

sessions_send

  • external channel-bound targets skip announce
  • unknown targets fail closed
  • zero-timeout sends do not wait on sessions.list, agent.wait, or chat.history
  • zero-timeout sends only use immediately provable routing information
  • metadata-backed routes that are only discoverable through lookup now fail closed at timeoutSeconds=0

tests

  • split registry-level sessions and subagents coverage
  • added focused zero-timeout regressions
  • restored real schema checks for sessions_send.timeoutSeconds
  • restored real schema checks for sessions_spawn.runTimeoutSeconds and legacy timeoutSeconds

Verification

pnpm test src/agents/tools/sessions-send-announce-guard.test.ts \
  src/agents/tools/sessions.test.ts \
  src/agents/openclaw-tools.sessions.test.ts \
  src/agents/openclaw-tools.subagents.test.ts \
  src/agents/openclaw-tools.sessions-visibility.test.ts

Result:

  • Test Files 5 passed
  • Tests 61 passed

Notes

  • zero-timeout sessions_send now prefers truthful fail-closed delivery reporting over lookup-dependent announce behavior
  • an independent review on the final diff found no remaining issues

Related issues

  • Related to #47515

  • Possibly related: #55981

  • Possibly related: #56136

  • Possibly related: #50487

Changed files

  • src/agents/openclaw-tools.sessions-visibility.test.ts (modified, +124/-9)
  • src/agents/openclaw-tools.sessions.test.ts (modified, +75/-405)
  • src/agents/openclaw-tools.subagents.test.ts (added, +717/-0)
  • src/agents/tools/sessions-announce-target.ts (modified, +144/-35)
  • src/agents/tools/sessions-send-announce-guard.test.ts (added, +794/-0)
  • src/agents/tools/sessions-send-tool.a2a.ts (modified, +22/-5)
  • src/agents/tools/sessions-send-tool.ts (modified, +72/-7)
  • src/agents/tools/sessions.test.ts (modified, +177/-7)
RAW_BUFFERClick to expand / collapse

Bug

When an agent receives an inter-agent message via sessions_send (sourceChannel=webchat) and replies to it, the reply routes to the OpenClaw webchat UI instead of the Discord channel where the conversation is happening.

Impact

Fleet agents on Discord cannot see each other's replies. The human operator (on Discord) becomes the relay for all inter-agent communication. This has been a persistent operational problem for 30+ days.

Steps to reproduce

  1. Agent A sends message to Agent B via sessions_send targeting agent B's Discord session key
  2. Agent B receives the message (sourceChannel=webchat)
  3. Agent B replies — reply goes to webchat, NOT to Agent A's Discord channel
  4. Agent A and the human on Discord never see the reply

Expected behavior

Reply should route back to the originating agent's Discord channel, or at minimum be visible in Discord.

Config context

  • Multi-agent fleet, all agents on separate Discord channels
  • Session keys: agent:{id}:discord:channel:{channelId}
  • Messages delivered via sessions_send with sourceChannel=webchat

Workaround

Agents must manually use the message tool to post to Discord after every inter-agent exchange. This is error-prone and adds overhead.

extent analysis

Fix Plan

The fix involves modifying the message routing logic to correctly handle inter-agent replies.

Step-by-Step Solution

  1. Update the sessions_send function to include the original Discord channel ID in the message payload.
  2. Modify the reply routing logic to check for the presence of the original Discord channel ID and route the reply accordingly.

Example Code

def sessions_send(message, target_session_key, source_channel):
    # Include the original Discord channel ID in the message payload
    message['original_discord_channel_id'] = get_discord_channel_id(target_session_key)
    # ... existing code ...

def handle_reply(reply, source_channel):
    # Check for the presence of the original Discord channel ID
    if 'original_discord_channel_id' in reply:
        # Route the reply to the original Discord channel
        discord_channel_id = reply['original_discord_channel_id']
        send_message_to_discord(reply, discord_channel_id)
    else:
        # ... existing code ...

def get_discord_channel_id(session_key):
    # Extract the Discord channel ID from the session key
    parts = session_key.split(':')
    return parts[-1]

def send_message_to_discord(message, discord_channel_id):
    # Send the message to the specified Discord channel
    # ... implementation details ...

Verification

To verify the fix, follow these steps:

  • Send a message from Agent A to Agent B via sessions_send.
  • Verify that Agent B receives the message.
  • Reply to the message from Agent B.
  • Verify that the reply is routed to Agent A's Discord channel.

Extra Tips

  • Ensure that the get_discord_channel_id function correctly extracts the Discord channel ID from the session key.
  • Test the fix with multiple agents and Discord channels to ensure that the reply routing logic works correctly in all scenarios.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Reply should route back to the originating agent's Discord channel, or at minimum be visible in Discord.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING