openclaw - 💡(How to fix) Fix [Bug] 多实例部署时 agent.id 默认为 main 导致 session 目录冲突 [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#58899Fetched 2026-04-08 02:31:23
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Code Example

// Friday
{ "agents": { "list": [{ "id": "main", "name": "Friday" }] } }

// Andy  
{ "agents": { "list": [{ "id": "main", "name": "Andy" }] } }

// vovo
{ "agents": { "list": [{ "id": "main", "name": "vovo" }] } }
RAW_BUFFERClick to expand / collapse

问题描述(由 Claude Code 发现并总结)

在部署多个 OpenClaw Gateway 实例时,如果不在配置中显式指定不同的 agent.id,所有实例默认使用 id: "main",导致它们共享同一个 session 目录。

复现场景

  1. 部署 Friday (port 18789)、Andy (port 18790)、vovo (port 18793) 三个独立 Gateway
  2. 每个实例有独立的 openclaw.jsonOPENCLAW_CONFIG_PATH
  3. 但如果不显式设置 agents.list[].id,默认都是 "id": "main"
  4. 导致三个实例的 session 都存储在 ~/.openclaw/agents/main/sessions/

当前行为

配置文件:

// Friday
{ "agents": { "list": [{ "id": "main", "name": "Friday" }] } }

// Andy  
{ "agents": { "list": [{ "id": "main", "name": "Andy" }] } }

// vovo
{ "agents": { "list": [{ "id": "main", "name": "vovo" }] } }

结果:

  • 三个实例的 Sessions 都指向 ~/.openclaw/agents/main/sessions/
  • session 历史混合在一起
  • 定时任务(如 cron)会互相干扰

期望行为

方案 1:警告但不阻止

  • 当检测到多个实例使用相同的 agent.id 时,输出警告日志

方案 2:自动生成唯一 ID

  • 如果不指定 agent.id,自动根据配置路径或实例名称生成唯一 ID

方案 3:文档增强

  • 在多实例部署文档中明确说明需要为每个实例设置不同的 agent.id

影响版本

  • OpenClaw 2026.3.24+
  • 多实例部署场景

相关配置

  • agents.list[].id
  • agents.defaults.workspace
  • agents.defaults.sessionsDir (当前似乎是无效配置)

extent analysis

TL;DR

To resolve the issue of multiple OpenClaw Gateway instances sharing the same session directory, explicitly specify a unique agent.id for each instance in the configuration.

Guidance

  • Review the configuration files for each instance (e.g., openclaw.json) and ensure that the agents.list[].id is unique for each instance.
  • Consider implementing one of the proposed solutions: warning on duplicate agent.id, auto-generating a unique ID, or enhancing documentation to emphasize the need for unique agent.id values.
  • Verify that the agents.defaults.sessionsDir configuration is correctly set and functional, as it may help in managing session directories for each instance.
  • Test the instances after applying the fix to ensure that each has its own session directory and that sessions are no longer mixed.

Example

// Example configuration for Friday with a unique agent.id
{ "agents": { "list": [{ "id": "friday-agent", "name": "Friday" }] } }

Notes

The issue seems to be specific to OpenClaw Gateway version 2026.3.24 and later, in scenarios with multiple instances deployed. The provided configurations and expected behaviors suggest that a unique agent.id is necessary for proper session management.

Recommendation

Apply workaround by explicitly specifying a unique agent.id for each instance, as this directly addresses the root cause of the issue and ensures that each instance has its own session directory.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING