-
-
Notifications
You must be signed in to change notification settings - Fork 69.5k
Matrix channel: replies in same room don't resolve thread ID (auto-injection missing) #32744
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Description
Problem
When using the Matrix channel plugin, replies sent to the same room do not resolve the thread ID automatically. This causes replies to appear as new messages instead of threaded replies.
Slack and Telegram have auto-thread-injection logic in resolveAndApplyOutboundThreadId() (via slackAutoThreadId and telegramAutoThreadId), but Matrix has no equivalent.
Current Workaround
We patch dist/reply-*.js after each update to add a resolveMatrixAutoThreadId() function that:
- Checks if
ctx.channel === "matrix"and no explicitthreadIdis set - Looks up
currentThreadTsandcurrentChannelIdfrom tool context - Compares normalized target room with current room
- Returns
currentThreadTsas the thread ID if they match
The patched line changes from:
const resolved = threadId ?? slackAutoThreadId ?? telegramAutoThreadId;To:
const resolved = threadId ?? slackAutoThreadId ?? telegramAutoThreadId ?? matrixAutoThreadId;Expected Behavior
Matrix should have native auto-thread-injection, similar to Slack and Telegram. When an agent replies to a message in a Matrix room, the reply should be threaded under the original message automatically.
Environment
- OpenClaw 2026.3.1
- Matrix plugin with Conduwuit homeserver
- Using per-room agent sessions (each room gets its own session)
Patch Code
# resolveMatrixAutoThreadId function added before resolveAndApplyOutboundThreadId
function resolveMatrixAutoThreadId(params) {
const context = params.toolContext;
if (!context?.currentThreadTs || !context.currentChannelId) return;
const to = params.to?.trim()?.toLowerCase();
const current = context.currentChannelId?.trim()?.toLowerCase();
if (!to || !current) return;
const normalizedTo = to.startsWith("room:") ? to.slice(5) : to;
const normalizedCurrent = current.startsWith("room:") ? current.slice(5) : current;
if (normalizedTo !== normalizedCurrent) return;
return context.currentThreadTs;
}This has been running stable in production since 2026-02-28.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.