← Back to PRs

#14852: feat(matrix): add multi-account support

by tfm-neo-ai open 2026-02-12 18:22 View on GitHub →
channel: matrix stale size: M
## Problem The Matrix plugin currently only supports a **single account**, while other channels like WhatsApp support multiple accounts via `channels.whatsapp.accounts`. ## Current Behavior In `extensions/matrix/src/matrix/accounts.ts`: ```typescript export function listMatrixAccountIds(_cfg: CoreConfig): string[] { return [DEFAULT_ACCOUNT_ID]; // Hardcoded single account } ``` This function completely ignores the config and hardcodes a single account ID. ## Expected Behavior Matrix should support the same multi-account pattern as WhatsApp: ```json5 channels: { matrix: { accounts: { personal: { homeserver: "https://matrix.personal.org", userId: "@me:personal.org", accessToken: "..." }, work: { homeserver: "https://matrix.company.org", userId: "@me:company.org", accessToken: "..." } } } } ``` ## Use Case Users who want to run multiple agents with different Matrix identities (e.g., personal vs. work) cannot do so with a single OpenClaw instance. They must run multiple OpenClaw instances as a workaround. ## Changes - Add `accounts` map to MatrixConfig schema - Add `MatrixAccountConfig` type for per-account settings - Update `listMatrixAccountIds()` to read from config.accounts - Update `resolveMatrixAccount()` to handle account-specific resolution - Add `resolveMatrixConfigForAccount()` for account-specific config merging - Add `loadMatrixCredentialsForAccount()` for account-specific credentials - Add comprehensive tests for multi-account functionality - Maintain backwards compatibility with single-account configs ## References - Fixes https://github.com/openclaw/openclaw/issues/14840 - WhatsApp multi-account schema: `src/config/zod-schema.providers-whatsapp.ts` - Matrix single-account code: `extensions/matrix/src/matrix/accounts.ts#L21-L23`

Most Similar PRs