Skip to content

fix: multi-channel attribution — all agents in Brain tab + /api/channels plugin filter#504

Open
vivekchand wants to merge 1 commit intomainfrom
fix/gh-clawmetry-503-multi-channel-agent-attribution
Open

fix: multi-channel attribution — all agents in Brain tab + /api/channels plugin filter#504
vivekchand wants to merge 1 commit intomainfrom
fix/gh-clawmetry-503-multi-channel-agent-attribution

Conversation

@vivekchand
Copy link
Copy Markdown
Owner

Closes #503

What

Two bugs caused multi-channel setups (e.g. Slack + WhatsApp) to appear broken:

1. Flow tab didn't show WhatsApp (or other plugin channels)
The /api/channels endpoint applied a directory-existence filter requiring ~/.openclaw/<channel>/ to exist. Channels configured as gateway plugins (WhatsApp, Discord, Slack) don't create standalone data directories, so they were silently filtered out and never rendered in the Flow visualization.

2. Brain tab showed all sessions tagged under main
Both api_brain_history and api_component_brain only scanned SESSIONS_DIR (the primary agents/main/sessions folder). Sessions from agents bound to other channels (e.g. a WhatsApp-bound agent at agents/dhriti/sessions) were completely omitted. Log lines always showed source: 'main' regardless of which agent generated them.

How

  • Added _get_all_agent_session_dirs() — scans all ~/.openclaw/agents/*/sessions and ~/.clawdbot/agents/*/sessions dirs, returns {agent_name: path} mapping.
  • api_brain_history — iterates all agent dirs from the helper; uses directory name as session source label (WhatsApp sessions now show as dhriti: or the actual agent name, not silently as main).
  • api_component_brain — same treatment; all agents' sessions included in stats with per-agent attribution.
  • /api/channels — trusts gateway config as the source of truth. Removed the directory filter for plugin-based channels. Directory discovery is now only used as a last resort fallback when config returns nothing.

Testing

  • With Slack + WhatsApp both configured as plugins: Flow tab should show both channel nodes
  • Brain tab sessions from non-main agents should appear with correct agent label
  • Single-channel setups (Telegram only) unaffected

…x /api/channels filter

Closes #503

## What
Two bugs caused multiple-channel setups (e.g. Slack + WhatsApp) to appear broken:

1. **/api/channels dropped non-Telegram channels** — The endpoint applied a
   directory-existence filter that required `~/.openclaw/<channel>/` to exist.
   Channels configured as gateway plugins (WhatsApp, Discord, Slack) don't
   create standalone data directories, so they were silently filtered out and
   never shown in the Flow tab.

2. **Brain tab attributed all sessions to 'main'** — Both `api_brain_history`
   and `api_component_brain` only scanned `SESSIONS_DIR` (the primary agent's
   sessions folder, defaulting to `agents/main/sessions`). Sessions from agents
   bound to other channels (e.g. a WhatsApp-bound agent at
   `agents/dhriti/sessions`) were completely omitted from the Brain feed.

## How
- Added `_get_all_agent_session_dirs()` helper that scans all
  `~/.openclaw/agents/*/sessions` directories and returns a mapping of
  `{agent_name: sessions_path}`.
- Updated `api_brain_history` to iterate all agent dirs and use the directory
  name as the session source label (so WhatsApp sessions show as `dhriti:`
  not silently as `main`).
- Updated `api_component_brain` to do the same — all agent sessions are now
  included in the Brain component stats with per-agent attribution.
- Simplified `/api/channels` to trust the gateway config as the source of
  truth. The directory filter is removed for plugin-based channels; directory
  discovery is now only used as a last resort when config yields nothing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mutiple channels

1 participant