-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
sessions_send hardcodes channel="webchat" causing silent misroute when target sessionKey is bound to a different channel #93255
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper 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 needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper 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 needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Type
Fields
Priority
None yet
Summary
sessions_sendsilently misroutes messages when the targetsessionKeyis bound to a channel other thanwebchat. The tool reportsstatus=acceptedand echoes the requestedsessionKeyback to the caller, but the message lands in a different sibling session for the same target agent — one that happens to be bound towebchat.Root cause:
sessions_sendhardcodeschannel: INTERNAL_MESSAGE_CHANNEL(="webchat") on the gatewayagentcall regardless of the target session's actual channel. When the gateway resolves the inbound by(sessionKey, channel)tuple, thechannelvalue wins over the explicit, fully-qualifiedsessionKey.User-facing harm
status=acceptedwith the correctsessionKeyechoed → no way to detect the misroute without manually checking session transcripts.Worked example (real receipts)
Two consecutive sends from two parallel sessions of the same agent, same target agent, same downstream worker (
b2184c98is the correct Telegram-bound analyst session,57c030a5is the analyst's webchat session for the same user).agent:main:telegram:default:direct:719408963(telegram)agent:analyst:main(alias)b2184c98(telegram)agent:main:telegram:default:direct:719408963(webchat)agent:analyst:telegram:analyst:direct:719408963(explicit)57c030a5(webchat)Both calls returned
status=accepted. Both echoed the requestedsessionKeyas if delivered correctly.The difference is the routing path: test A goes through
ensureConfiguredAgentMainSessionbecause it's a configured-main alias; test B short-circuits that path because the target is a fully-qualified non-main key.Code pinpoint (openclaw 6.x dist)
dist/openclaw-tools-C0nKaVVY.js~ line 10460, insidecreateSessionsSendTool().execute:dist/message-channel-constants-CgI32lqD.jsline 2:Why test A works:
agent:analyst:mainhitsisConfiguredAgentMainSessionKey()→ true →ensureConfiguredAgentMainSession()callssessions.resolve {key: "agent:analyst:main"}which resolves to the currently-active analyst session (Telegram in our case). The hardcoded webchat channel doesn't override that explicit resolve.Why test B fails: Fully-qualified non-main key short-circuits
ensureConfiguredAgentMainSession(returns{ok:true}immediately). The gatewayagentmethod then receives raw{sessionKey: <telegram-direct>, channel: "webchat"}and channel-tuple lookup picks the analyst's webchat-bound session for that user.Proposed fix (option 1 — minimal, tool-layer)
Hoist the existing
loadSessionEntryByKey(resolvedKey)call (it's already invoked a few lines below fortargetSessionEntry) and derive the channel from the resolved session's binding instead of hardcoding:3-line patch. No new dependencies. Preserves webchat-default for sessions without a known channel binding.
Proposed fix (option 2 — cleaner, gateway-layer)
Treat fully-qualified explicit
sessionKeyas authoritative for inbound routing.channelbecomes a hint (for provenance, reply-routing) but never a routing modifier whensessionKeyis explicit. This is more invasive but fixes a class of bugs rather than one instance.We'd defer to maintainer judgment on which option fits the gateway's architecture better. Option 1 is a 3-line patch that closes the immediate silent-misroute; option 2 is the principled fix.
Reproducer
target) with two live sessions: one bound to Telegram (sessionKey likeagent:target:telegram:target:direct:<userId>), one bound to webchat.sessions_sendwith the explicit Telegram-bound sessionKey as the target.target's webchat session, not the Telegram one. Tool reportsacceptedwith the Telegram sessionKey echoed.Environment
dist/)Severity
P2 — silent misroute, no data loss, recoverable via verify-before-act discipline, but invisible until it causes duplicate downstream work. In our INC-022 case it caused ~25 minutes of confused investigation across three agents before being traced to the routing tuple.
Related
fetch failedwith emptycontent:[]— separate issue to be filed)