Skip to content

[Bug]: Implicit "main" agent not in agents.list causes "Session file path must be within sessions directory" on all channel messages #16271

Description

@angus-git-guru

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

  1. 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" }
  ]
}
  1. Enable Telegram (or any channel) with dmPolicy: "allowlist"
  2. Send a DM to the bot from an allowed user
  3. Observe error in logs: [telegram] handler failed: Error: Session file path must be within sessions directory
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions