fix: multi-channel attribution — all agents in Brain tab + /api/channels plugin filter#504
Open
vivekchand wants to merge 1 commit intomainfrom
Open
fix: multi-channel attribution — all agents in Brain tab + /api/channels plugin filter#504vivekchand wants to merge 1 commit intomainfrom
vivekchand wants to merge 1 commit intomainfrom
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/channelsendpoint 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
mainBoth
api_brain_historyandapi_component_brainonly scannedSESSIONS_DIR(the primaryagents/main/sessionsfolder). Sessions from agents bound to other channels (e.g. a WhatsApp-bound agent atagents/dhriti/sessions) were completely omitted. Log lines always showedsource: 'main'regardless of which agent generated them.How
_get_all_agent_session_dirs()— scans all~/.openclaw/agents/*/sessionsand~/.clawdbot/agents/*/sessionsdirs, 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 asdhriti:or the actual agent name, not silently asmain).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