← Back to library

Per-Agent BOOT.md:多代理启动时逐个执行引导脚本

问题/场景:多代理配置下仅默认代理执行 BOOT.md,会导致其余代理缺少初始化上下文。前置条件:已配置多个 agent 且各自 workspace 需要启动钩子。实施步骤:遍历 listAgentIds → 按 agent 解析 workspace → 为每个 agent 调用 runBootOnce。关键命令:openclaw gateway restart。验证:启动日志中每个 agent 都有 BOOT.md 执行记录。风险:初始化脚本耗时会拉长启动时间。来源:PR #20569。

GITHUBDiscovered 2026-02-19Author mcaxtr
Prerequisites
  • More than one agent is configured and each may have agent-specific BOOT.md setup tasks.
  • You can inspect startup logs and adjust hook timeout if required.
Steps
  1. List configured agent IDs at startup instead of assuming only default agent.
  2. Resolve each agent workspace path and session key independently.
  3. Run BOOT hook once per agent and isolate failures so one agent does not block all others.
  4. After restart, inspect logs to confirm all agents completed boot hook execution.
Commands
openclaw gateway restart
openclaw gateway status
Verify

Every configured agent shows BOOT.md execution trace during startup, not only the default agent.

Caveats
  • Long-running BOOT tasks can delay readiness; keep BOOT.md idempotent and lightweight.
  • Agent workspace path mismatches can silently skip hooks if not validated(需验证).
Source attribution

This tip is aggregated from community/public sources and preserved with attribution.

Open original source ↗
Visit original post