Summary
When agents.list defines non-default agents (e.g. host-cron, coding) but does NOT explicitly include the implicit main agent, all inbound channel messages (Telegram, Slack, WhatsApp) fail with Session file path must be within sessions directory. The main agent exists implicitly as the code default (DEFAULT_AGENT_ID = "main") and has a working sessions directory at ~/.openclaw/agents/main/sessions/, but the session path validation in resolvePathWithinSessionsDir() rejects absolute sessionFile paths from other agents when resolved against the main agent's sessions directory. Related to #15141 which was fixed in 2026.2.13, but the root cause (implicit vs explicit agent registration) persists.
Steps to reproduce
- Configure
agents.list with a non-default agent (e.g. host-cron) but do NOT include main in the list:
"agents": {
"list": [
{ "id": "host-cron", "name": "Host Cron Runner", "workspace": "~/.openclaw/workspace" }
]
}
- Enable Telegram (or any channel) with
dmPolicy: "allowlist"
- Send a DM to the bot from an allowed user
- Observe error in logs:
[telegram] handler failed: Error: Session file path must be within sessions directory
- The bot receives the message (shows read receipts) but never responds
Expected behavior
Inbound channel messages should be processed and the agent should respond, regardless of whether main is explicitly listed in agents.list. The implicit main agent should work the same as an explicitly registered one for session path resolution.
Actual behavior
Every inbound Telegram message fails with:
[telegram] handler failed: Error: Session file path must be within sessions directory
The bot shows read receipts (eyes emoji) but never responds. The error occurs because resolvePathWithinSessionsDir() resolves the non-default agent's absolute sessionFile path against the main agent's sessions directory. For example, /Users/user/.openclaw/agents/host-cron/sessions/abc123.jsonl resolved against /Users/user/.openclaw/agents/main/sessions/ produces a relative path starting with ../ which fails the security check.
Adding main explicitly to agents.list resolves the issue immediately.
OpenClaw version
2026.2.12 and 2026.2.13
Operating system
macOS 26.2 (arm64) - Mac mini M4
Install method
npm global
Logs, screenshots, and evidence
2026-02-14T12:30:57.855Z [telegram] handler failed: Error: Session file path must be within sessions directory
2026-02-14T12:36:31.649Z [telegram] handler failed: Error: Session file path must be within sessions directory
2026-02-14T13:48:07.670Z [telegram] handler failed: Error: Session file path must be within sessions directory
The error fires on every inbound Telegram DM. The bot receives the message (shows read receipts/eyes emoji) but never processes or responds.
Config at time of error:
"agents": {
"list": [
{ "id": "host-cron", "name": "Host Cron Runner", "workspace": "/Users/angus/.openclaw/workspace" },
{ "id": "coding", "name": "Coding Agent" }
]
}
Note: `main` is NOT in the list. Adding it fixes the issue:
{ "id": "main", "name": "Main Agent", "workspace": "/Users/angus/.openclaw/workspace" }
Impact and severity
Additional information
Summary
When
agents.listdefines non-default agents (e.g.host-cron,coding) but does NOT explicitly include the implicitmainagent, all inbound channel messages (Telegram, Slack, WhatsApp) fail withSession file path must be within sessions directory. Themainagent exists implicitly as the code default (DEFAULT_AGENT_ID = "main") and has a working sessions directory at~/.openclaw/agents/main/sessions/, but the session path validation inresolvePathWithinSessionsDir()rejects absolutesessionFilepaths from other agents when resolved against themainagent's sessions directory. Related to #15141 which was fixed in 2026.2.13, but the root cause (implicit vs explicit agent registration) persists.Steps to reproduce
agents.listwith a non-default agent (e.g.host-cron) but do NOT includemainin the list:dmPolicy: "allowlist"[telegram] handler failed: Error: Session file path must be within sessions directoryExpected behavior
Inbound channel messages should be processed and the agent should respond, regardless of whether
mainis explicitly listed inagents.list. The implicitmainagent should work the same as an explicitly registered one for session path resolution.Actual behavior
Every inbound Telegram message fails with:
The bot shows read receipts (eyes emoji) but never responds. The error occurs because
resolvePathWithinSessionsDir()resolves the non-default agent's absolutesessionFilepath against themainagent's sessions directory. For example,/Users/user/.openclaw/agents/host-cron/sessions/abc123.jsonlresolved against/Users/user/.openclaw/agents/main/sessions/produces a relative path starting with../which fails the security check.Adding
mainexplicitly toagents.listresolves the issue immediately.OpenClaw version
2026.2.12 and 2026.2.13
Operating system
macOS 26.2 (arm64) - Mac mini M4
Install method
npm global
Logs, screenshots, and evidence
Impact and severity
mainis not explicitly inagents.listbut other agents are. Affects all channel types (Telegram confirmed, likely WhatsApp/Slack/Discord too based on [Bug] Session file path validation failure in v2026.2.12 causing Telegram handler crashes #15141 and Multi-agent routing: session ID validation rejects auto-generated WhatsApp DM session keys #16211).openclaw doctorandopenclaw statusboth report Telegram as OK.Additional information
agentIdto session resolution, which helps but does not cover the case wheremainis implicit (not inagents.list). Whenmainis missing from the list, some code paths still fall back toDEFAULT_AGENT_ID = "main"without properly resolving its sessions directory.mainexplicitly toagents.listinopenclaw.json.session.store: "~/.openclaw/agents/{agentId}/sessions/sessions.json"to force per-agent store resolution.mainwhen it's not in the list, oropenclaw doctorshould warn whenmainis missing fromagents.listin a multi-agent setup.