Project Manager Agent
Description
Monitors active sub-agents, detects stalls, provides status updates, and steers stuck agents via sessions_send.
Project Manager Agent
This skill provides oversight for your OpenClaw sub-agents. It proactively checks the status of running sub-agents, identifies potential stalls or failures, and can steer stalled sub-agents by sending a continue message via the sessions_send tool.
Usage
Running the monitor
CODEBLOCK0
Options
- -
--staleness_threshold_minutes <int>: Minutes after which a sub-agent is considered stalled (default from config or 10). - INLINECODE1 : Check all sessions, not just subagents of the current main session.
- INLINECODE2 : Print human summary then a JSON line with
stalledSessionKeys, steerMessage, and summary for agent steering. - INLINECODE6 : Output all stalled keys (ignore 15-minute cooldown).
- INLINECODE7 : Record these session keys as just steered (for cooldown). Run after calling sessions_send.
Example (Status check, human-only)
CODEBLOCK1
Example (Agent run with steering)
CODEBLOCK2
Then parse the last line (JSON), call sessions_send for each key in stalledSessionKeys, and optionally run --record-steered <keys>.
Features
- - Sub-agent Monitoring: Lists all active sub-agents (file-based; no gateway API in the script).
- Stall Detection: Flags sub-agents that haven't updated their status within a configurable time period.
- Failure Identification: Reports on sub-agents that have aborted their last run.
- Status Reports: Human-readable summaries and optional JSON with
stalledSessionKeys for steering. - Automated Steering: When you run the skill with
--json, parse the output and call sessions_send for each stalled session (see Agent instructions below).
Agent instructions (mandatory when running this skill)
When the user or a cron asks you to run the project-manager-agent skill:
- 1. Run the script with
--json (and existing args as needed):
python3 /Users/ghost/.openclaw/workspace/skills/project-manager-agent/scripts/project_manager.py --json --staleness_threshold_minutes 10
- 2. Parse the script stdout: The last line is a single JSON object with
stalledSessionKeys, steerMessage, and summary. Parse it (e.g. take the last line that starts with { and ends with }). - If
stalledSessionKeys is non-empty:
- For each session key in
stalledSessionKeys (cap at 5 per run to avoid spam), call
sessions_send(
sessionKey,
steerMessage from JSON or
"Please continue working on your task.",
0) (fire-and-forget;
timeoutSeconds=0).
- Optionally run the script again to record cooldown so the same session is not steered again for 15 minutes:
python3 /Users/ghost/.openclaw/workspace/skills/project-manager-agent/scripts/project_manager.py --record-steered <key1> <key2> ...
- 4. Reply to the user/cron with the status summary (the human-readable part of the script output) and, if you steered any, add: "Steered N stalled subagent(s)."
You have access to sessionslist and sessionssend; the script only produces the list of session keys to steer. Steering is done by you in the same turn via the sessions_send tool.
Config (optional)
See config.json for: staleness_threshold_minutes, steer_cooldown_minutes, steer_message, max_steer_per_run.
Integration as a Cron Job
This skill is ideal for a cron job, running periodically (e.g., every 5 minutes). The agent runs the script with --json, steers stalled subagents via sessions_send, and announces the status.
Example Cron Job Payload:
CODEBLOCK5
version: 0.2.0
项目经理代理
描述
监控活跃的子代理,检测停滞,提供状态更新,并通过 sessions_send 引导卡住的代理。
项目经理代理
此技能为您的 OpenClaw 子代理提供监督。它会主动检查运行中的子代理状态,识别潜在的停滞或故障,并可通过 sessions_send 工具发送继续消息来引导停滞的子代理。
使用方法
运行监控器
bash
python3 <技能目录>/scripts/project_manager.py
选项
- - --stalenessthresholdminutes <整数>:子代理被视为停滞的分钟数阈值(默认来自配置或10分钟)。
- --checkallsessions:检查所有会话,而不仅仅是当前主会话的子代理。
- --json:打印人类可读摘要,然后输出包含 stalledSessionKeys、steerMessage 和 summary 的 JSON 行,用于代理引导。
- --nocooldown:输出所有停滞的键(忽略15分钟冷却时间)。
- --record-steered 键 [键 ...]:将这些会话键记录为刚刚被引导(用于冷却)。在调用 sessionssend 后运行。
示例(状态检查,仅人类可读)
bash
python3 /Users/ghost/.openclaw/workspace/skills/project-manager-agent/scripts/projectmanager.py --stalenessthreshold_minutes 15
示例(带引导的代理运行)
bash
python3 /Users/ghost/.openclaw/workspace/skills/project-manager-agent/scripts/projectmanager.py --json --stalenessthreshold_minutes 10
然后解析最后一行(JSON),为 stalledSessionKeys 中的每个键调用 sessions_send,并可选择运行 --record-steered <键>。
功能特性
- - 子代理监控:列出所有活跃的子代理(基于文件;脚本中无网关 API)。
- 停滞检测:标记在可配置时间段内未更新状态的子代理。
- 故障识别:报告上次运行已中止的子代理。
- 状态报告:人类可读的摘要和可选的包含 stalledSessionKeys 的 JSON,用于引导。
- 自动引导:当您使用 --json 运行技能时,解析输出并为每个停滞的会话调用 sessions_send(参见下面的代理说明)。
代理说明(运行此技能时必须遵守)
当用户或定时任务要求您运行 project-manager-agent 技能时:
- 1. 使用 --json 运行脚本(并根据需要添加现有参数):
bash
python3 /Users/ghost/.openclaw/workspace/skills/project-manager-agent/scripts/project
manager.py --json --stalenessthreshold_minutes 10
- 2. 解析脚本的标准输出:最后一行是一个包含 stalledSessionKeys、steerMessage 和 summary 的 JSON 对象。解析它(例如,取以 { 开头并以 } 结尾的最后一行)。
- 如果 stalledSessionKeys 非空:
- 对于 stalledSessionKeys 中的每个会话键(每次运行最多5个以避免垃圾信息),调用
sessions_send(sessionKey,steerMessage(来自 JSON 或 请继续处理您的任务。),0)(即发即忘;timeoutSeconds=0)。
- 可选择再次运行脚本以记录冷却时间,使同一会话在15分钟内不会被再次引导:
bash
python3 /Users/ghost/.openclaw/workspace/skills/project-manager-agent/scripts/project_manager.py --record-steered <键1> <键2> ...
- 4. 回复用户/定时任务,提供状态摘要(脚本输出的人类可读部分),如果您引导了任何代理,则添加:已引导 N 个停滞的子代理。
您可以访问 sessionslist 和 sessionssend;脚本仅生成要引导的会话键列表。引导操作由您在同一轮次中通过 sessions_send 工具完成。
配置(可选)
参见 config.json 中的:stalenessthresholdminutes、steercooldownminutes、steermessage、maxsteerperrun。
作为定时任务集成
此技能非常适合作为定时任务,定期运行(例如,每5分钟)。代理使用 --json 运行脚本,通过 sessions_send 引导停滞的子代理,并宣布状态。
示例定时任务负载:
json
{
payload: {
kind: agentTurn,
message: 运行 project-manager-agent 技能并报告所有子代理的状态。,
model: openrouter/google/gemini-2.5-flash,
thinking: low,
timeoutSeconds: 60
},
schedule: {
kind: every,
everyMs: 300000
},
delivery: {
mode: announce
},
sessionTarget: isolated,
name: 项目经理(子代理监控器)
}
版本:0.2.0