From 2c653096eb332c0e9df439874fcd2f83c258f93a Mon Sep 17 00:00:00 2001 From: Claudia Date: Sun, 1 Feb 2026 12:18:25 +0100 Subject: [PATCH] fix: pass accountId to resolveAgentRoute for multi-account routing The handler was calling resolveAgentRoute without accountId, causing all Matrix messages to route to the default agent regardless of which account received them. Changes: - Add accountId to MatrixMonitorHandlerParams type - Extract accountId in createMatrixRoomMessageHandler - Pass accountId to resolveAgentRoute call - Pass accountId from monitorMatrixProvider to handler --- src/matrix/monitor/handler.ts | 4 ++++ src/matrix/monitor/index.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/src/matrix/monitor/handler.ts b/src/matrix/monitor/handler.ts index cd631f351..1753da233 100644 --- a/src/matrix/monitor/handler.ts +++ b/src/matrix/monitor/handler.ts @@ -79,6 +79,8 @@ export type MatrixMonitorHandlerParams = { }; getRoomInfo: (roomId: string) => Promise<{ name?: string; canonicalAlias?: string; altAliases: string[] }>; getMemberDisplayName: (roomId: string, userId: string) => Promise; + /** Account ID for multi-account routing */ + accountId?: string | null; }; export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParams) { @@ -104,6 +106,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam directTracker, getRoomInfo, getMemberDisplayName, + accountId, } = params; return async (roomId: string, event: MatrixRawEvent) => { @@ -442,6 +445,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam const route = core.channel.routing.resolveAgentRoute({ cfg, channel: "matrix", + accountId: accountId ?? undefined, peer: { kind: isDirectMessage ? "dm" : "channel", id: isDirectMessage ? senderId : roomId, diff --git a/src/matrix/monitor/index.ts b/src/matrix/monitor/index.ts index 2b18a8114..f02293fa2 100644 --- a/src/matrix/monitor/index.ts +++ b/src/matrix/monitor/index.ts @@ -223,6 +223,7 @@ export async function monitorMatrixProvider(opts: MonitorMatrixOpts = {}): Promi directTracker, getRoomInfo, getMemberDisplayName, + accountId: opts.accountId, }); registerMatrixMonitorEvents({