openclaw - 💡(How to fix) Fix [Bug] Webchat messages routed to subagent session instead of main session [1 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#57333Fetched 2026-04-08 01:50:53
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Fix Action

Workaround

None known. User must wait for subagent to complete before sending messages, or risk messages going to wrong session.

RAW_BUFFERClick to expand / collapse

[Bug] Webchat messages routed to subagent session instead of main session

File this at: https://github.com/openclaw/openclaw/issues/new


Bug Description

Messages sent from webchat were incorrectly routed to an active subagent session instead of the main session. The user was not replying to a specific message — they were sending fresh messages to the chat.

Steps to Reproduce

  1. Start a main session on webchat
  2. Spawn a subagent via sessions_spawn (e.g., alex-rivera-dashboard-v2)
  3. While the subagent is actively running, send new messages from webchat
  4. Messages are routed to the subagent session instead of main

Expected Behavior

All webchat messages should route to agent:main:main (the main session). Subagent sessions should only receive:

  • Internal task prompts from sessions_spawn
  • Completion events
  • Explicit sessions_send messages

Users should never accidentally talk directly to subagents.

Actual Behavior

Messages sent during active subagent execution were routed to agent:main:subagent:<uuid> instead of agent:main:main.

From session list:

  • Main session: agent:main:main (channel: webchat)
  • Subagent: agent:main:subagent:97fad762-1018-42e8-91a1-8615146bd785 (label: alex-rivera-dashboard-v2, channel: telegram, spawnedBy: agent:main:main)

User messages about "landing zone", "SQL db", "auth for Jordan", and "connect folder" ended up in the subagent session transcript instead of main.

Impact

  • Main session appeared unresponsive for ~10 minutes while waiting for user input
  • User thought the system was stuck
  • Work happened in wrong context (subagent processed requests meant for orchestrator)

Environment

  • OpenClaw version: 2026.3.28
  • Channel: webchat
  • OS: Linux

Relevant Docs

From channel-routing.md:

WebChat behavior: WebChat attaches to the selected agent and defaults to the agent's main session.

From subagents.md:

Thread-bound sessions ... Thread supporting channels: Discord (currently the only supported channel)

Webchat should not have thread-binding behavior, yet messages were routed as if bound to the subagent.

Workaround

None known. User must wait for subagent to complete before sending messages, or risk messages going to wrong session.

extent analysis

Fix Plan

To fix the issue of webchat messages being routed to subagent sessions instead of the main session, we need to modify the channel routing logic.

  • Update the channel-routing.md to include a check for active subagent sessions and ensure that webchat messages are always routed to the main session.
  • Modify the sessions_spawn function to include a flag indicating that the subagent session should not receive webchat messages.
  • Update the webchat attachment logic to always default to the main session, regardless of active subagent sessions.

Example code snippet:

def route_webchat_message(message):
    # Check if there's an active subagent session
    active_subagent = get_active_subagent()
    if active_subagent:
        # Route message to main session
        route_message_to_main_session(message)
    else:
        # Route message to selected agent's main session
        route_message_to_selected_agent(message)

def get_active_subagent():
    # Query the database for active subagent sessions
    subagents = query_database("SELECT * FROM subagents WHERE status = 'active'")
    if subagents:
        return subagents[0]
    return None

def route_message_to_main_session(message):
    # Route the message to the main session
    main_session = get_main_session()
    main_session.receive_message(message)

def route_message_to_selected_agent(message):
    # Route the message to the selected agent's main session
    selected_agent = get_selected_agent()
    selected_agent.main_session.receive_message(message)

Verification

To verify that the fix worked, follow these steps:

  • Start a main session on webchat
  • Spawn a subagent via sessions_spawn
  • Send new messages from webchat while the subagent is actively running
  • Check that the messages are routed to the main session instead of the subagent session

Extra Tips

  • Make sure to update the documentation to reflect the changes made to the channel routing logic.
  • Consider adding additional logging to track the routing of webchat messages and identify any potential issues.
  • Review the code for any potential edge cases or scenarios that may not be handled by the updated logic.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug] Webchat messages routed to subagent session instead of main session [1 participants]