常设订单
常设指令为你的代理授予针对已定义程序的永久操作权限。你无需为每个任务向代理提示,而是定义具有明确范围、触发条件和升级规则的程序,代理会在这些边界内自主执行:“你负责周报。每周五汇总并发送,只有在发现异常时才升级。”
为什么使用常设指令¶
没有常设指令: 你为每个任务向代理提示,例行工作容易被遗忘或延迟,你成为瓶颈。
有了常设指令: 代理在定义好的边界内自主执行,例行工作按计划进行,你只处理例外和审批。
工作原理¶
常设指令定义在你的代理工作区文件中。推荐做法是直接将它们包含在 AGENTS.md(每次会话都会自动注入)中,以便代理始终在上下文中拥有它们。对于更大的配置,你也可以将它们放在专用文件中,例如 standing-orders.md,并从 AGENTS.md 引用它。
对于严格的、临时性的 CI 或脚本入口点,请使用 openclaw agent exec。它会跳过工作区引导文件,因此每次一次性运行都是自包含的,而不是受常设指令约束。
每个程序指定:
- 范围 - 代理被授权做什么
- 触发器 - 何时执行(计划、事件或条件)
- 审批关卡 - 行动前需要人工签核的内容
- 升级规则 - 何时停止并寻求帮助
代理每次会话都会通过工作区引导文件加载这些指令(自动注入文件的完整列表见代理工作区),并据此执行,同时结合自动化实现基于时间的强制执行。
Tip
将常设指令放在 AGENTS.md 中,以确保每次会话都会加载。工作区引导会自动注入 AGENTS.md、SOUL.md、IDENTITY.md、USER.md、BOOTSTRAP.md 和 MEMORY.md,但不会注入子目录中的任意文件。
常设指令的结构¶
## Program: Weekly Status Report
**Authority:** Compile data, generate report, deliver to stakeholders
**Trigger:** Every Friday at 4 PM (enforced via automation job)
**Approval gate:** None for standard reports. Flag anomalies for human review.
**Escalation:** If data source is unavailable or metrics look unusual (>2σ from norm)
### Execution steps
1. Pull metrics from configured sources
2. Compare to prior week and targets
3. Generate report in Reports/weekly/YYYY-MM-DD.md
4. Deliver summary via configured channel
5. Log completion to Agent/Logs/
### What NOT to do
- Do not send reports to external parties
- Do not modify source data
- Do not skip delivery if metrics look bad - report accurately
常设指令与自动化¶
常设指令定义代理被授权做什么。自动化定义何时发生。它们协同工作:
Standing Order: "You own the daily inbox triage"
↓
Automation (8 AM daily): "Execute inbox triage per standing orders"
↓
Agent: Reads standing orders → executes steps → reports results
自动化任务提示应引用常设指令,而不是重复它(openclaw automations;openclaw cron 仍为别名):
openclaw automations add \
--name daily-inbox-triage \
--cron "0 8 * * 1-5" \
--tz America/New_York \
--timeout-seconds 300 \
--announce \
--channel imessage \
--to "+1XXXXXXXXXX" \
--message "Execute daily inbox triage per standing orders. Check mail for new alerts. Parse, categorize, and persist each item. Report summary to owner. Escalate unknowns."
示例¶
示例 1:内容与社交媒体(每周循环)¶
## Program: Content & Social Media
**Authority:** Draft content, schedule posts, compile engagement reports
**Approval gate:** All posts require owner review for first 30 days, then standing approval
**Trigger:** Weekly cycle (Monday review → mid-week drafts → Friday brief)
### Weekly cycle
- **Monday:** Review platform metrics and audience engagement
- **Tuesday-Thursday:** Draft social posts, create blog content
- **Friday:** Compile weekly marketing brief → deliver to owner
### Content rules
- Voice must match the brand (see SOUL.md or brand voice guide)
- Never identify as AI in public-facing content
- Include metrics when available
- Focus on value to audience, not self-promotion
示例 2:财务运营(事件触发)¶
## Program: Financial Processing
**Authority:** Process transaction data, generate reports, send summaries
**Approval gate:** None for analysis. Recommendations require owner approval.
**Trigger:** New data file detected OR scheduled monthly cycle
### When new data arrives
1. Detect new file in designated input directory
2. Parse and categorize all transactions
3. Compare against budget targets
4. Flag: unusual items, threshold breaches, new recurring charges
5. Generate report in designated output directory
6. Deliver summary to owner via configured channel
### Escalation rules
- Single item > $500: immediate alert
- Category > budget by 20%: flag in report
- Unrecognizable transaction: ask owner for categorization
- Failed processing after 2 retries: report failure, do not guess
示例 3:监控与告警(持续)¶
## Program: System Monitoring
**Authority:** Check system health, restart services, send alerts
**Approval gate:** Restart services automatically. Escalate if restart fails twice.
**Trigger:** Every heartbeat cycle
### Checks
- Service health endpoints responding
- Disk space above threshold
- Pending tasks not stale (>24 hours)
- Delivery channels operational
### Response matrix
| Condition | Action | Escalate? |
| ---------------- | ------------------------ | ------------------------ |
| Service down | Restart automatically | Only if restart fails 2x |
| Disk space < 10% | Alert owner | Yes |
| Stale task > 24h | Remind owner | No |
| Channel offline | Log and retry next cycle | If offline > 2 hours |
执行-验证-报告模式¶
常设指令在与严格的执行纪律结合时效果最佳。常设指令中的每个任务都应遵循此循环:
- 执行 - 完成实际工作(不要只是确认指令)
- 验证 - 确认结果正确(文件存在、消息已送达、数据已解析)
- 报告 - 告知所有者已完成什么以及已验证什么
### Execution rules
- Every task follows Execute-Verify-Report. No exceptions.
- "I'll do that" is not execution. Do it, then report.
- "Done" without verification is not acceptable. Prove it.
- If execution fails: retry once with adjusted approach.
- If still fails: report failure with diagnosis. Never silently fail.
- Never retry indefinitely - 3 attempts max, then escalate.
该模式可防止最常见的智能体失败模式:确认任务但未完成任务。
多程序架构¶
对于管理多个关注点的智能体,请将常设指令组织为具有清晰边界的独立程序:
## Program 1: [Domain A] (Weekly)
...
## Program 2: [Domain B] (Monthly + On-Demand)
...
## Program 3: [Domain C] (As-Needed)
...
## Escalation Rules (All Programs)
- [Common escalation criteria]
- [Approval gates that apply across programs]
每个程序应具备:
- 其自身的触发频率(每周、每月、事件驱动、持续)
- 其自身的审批关卡(某些程序比其他程序需要更多监督)
- 清晰的边界(智能体应知道一个程序在哪里结束、另一个程序在哪里开始)
最佳实践¶
应该做¶
- 从有限的权限开始,随着信任建立逐步扩大
- 为高风险操作定义明确的审批关卡
- 包含“不要做什么”部分 - 边界与权限同样重要
- 与自动化结合,以实现可靠的时间触发执行
- 每周审查智能体日志,以验证常设指令是否被遵循
- 随着需求变化更新常设指令——它们是活文档
避免¶
- 第一天就授予广泛权限(“做你认为最好的事”)
- 跳过升级规则——每个程序都需要“何时停止并询问”条款
- 假设智能体会记住口头指令——把所有内容写入文件
- 在单个程序中混合多个关注点——不同领域应使用独立程序
- 忘记通过自动化强制执行——没有触发器的常设指令只会变成建议
相关¶
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 cl/openclaw