智能体自主原语:构建自导向 AI 智能体 - Openclaw Skills
作者:互联网
2026-04-06
什么是 智能体自主原语?
智能体自主原语提供了将 AI 智能体从被动聊天界面进化为主动、独立工作者所需的基础设施。通过在 Openclaw Skills 中实施该系统,开发人员可以为智能体配备管理自身待办事项、记录内部推理以及在多个执行周期中保持持久状态的能力。
该框架围绕五个核心支柱构建:类型化记忆、任务文件、项目分组、模板架构和心跳循环。这些原语共同为智能体操作创建了一种标准语言,实现了不同智能体架构与 Obsidian 等人类可读界面之间的无缝集成。这确保了所做的每一个决策和完成的每一项任务都以透明、结构化的格式进行跟踪。
下载入口:https://github.com/openclaw/skills/tree/main/skills/g9pedro/agent-autonomy-primitives
安装与下载
1. ClawHub CLI
从源直接安装技能的最快方式。
npx clawhub@latest install agent-autonomy-primitives
2. 手动安装
将技能文件夹复制到以下位置之一
全局模式~/.openclaw/skills/
工作区
/skills/
优先级:工作区 > 本地 > 内置
3. 提示词安装
将此提示词复制到 OpenClaw 即可自动安装。
请帮我使用 Clawhub 安装 agent-autonomy-primitives。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
智能体自主原语 应用场景
- 为长期运行的 AI 智能体操作建立持久的自主循环。
- 实施任务驱动型执行,使智能体根据元数据优先处理自己的工作队列。
- 构建通过共享记忆和任务库进行协作的多智能体系统。
- 创建智能体决策和经验教训的可验证审计追踪,以供人类审查。
- 跨不同的 Openclaw Skills 和智能体框架标准化组织工作流。
- 初始化:开发人员建立一个结构化库,作为智能体的长期记忆和工作空间。
- 任务定义:将工作分解为基于 Markdown 的任务文件,其中包含用于优先级和状态等元数据的 YAML 前置内容。
- 心跳触发:建立周期性唤醒周期(心跳),以定期触发智能体的逻辑。
- 执行周期:在每个心跳期间,智能体读取任务队列,选择优先级最高的项目并执行工作。
- 状态更新:完成或阻塞时,智能体更新任务状态,并将任何新记忆或教训记录回库中。
- 反思:智能体利用存储的教训和决策来指导未来的执行周期,创建一个持续改进的闭环。
智能体自主原语 配置指南
要开始使用智能体自主原语,请安装核心 CLI 工具并初始化您的智能体库:
npm install -g clawvault
clawvault init
然后,您可以定义第一个项目和任务以开始自主工作流程:
# 创建项目范围
clawvault project add "Autonomous Research" --owner my-agent
# 添加初始任务
clawvault task add "Analyze market trends" --priority high --owner my-agent --project autonomous-research
智能体自主原语 数据架构与分类体系
该技能使用带有 YAML 前置内容的 Markdown 文件将数据组织成清晰的目录结构。这种结构针对 Openclaw Skills 内部的程序化访问和人类可读性进行了优化。
| 原语 | 目录 | 元数据字段 |
|---|---|---|
| 任务 | tasks/ |
状态, 优先级, 所有者, 项目, 截止日期, 标签 |
| 决策 | decisions/ |
理由, 上下文, 日期 |
| 教训 | lessons/ |
经验, 解决方案, 相关任务 |
| 项目 | projects/ |
目标, 所有者, 客户, 截止日期 |
| 模板 | templates/ |
自定义字段的架构定义 |
name: agent-autonomy-primitives
description: Build long-running autonomous agent loops using ClawVault primitives (tasks, projects, memory types, templates, heartbeats). Use when setting up agent autonomy, creating task-driven execution loops, customizing primitive schemas, wiring heartbeat-based work queues, or teaching an agent to manage its own backlog. Also use when adapting primitives to an existing agent setup or designing multi-agent collaboration through shared vaults.
Agent Autonomy Primitives
Turn any AI agent into a self-directing worker using five composable primitives: typed memory, task files, project grouping, template schemas, and heartbeat loops.
Prerequisites
npm install -g clawvault
clawvault init
The Five Primitives
1. Typed Memory
Every memory has a type. The type determines where it lives and how it's retrieved.
| Type | Directory | When to Use |
|---|---|---|
decision |
decisions/ |
Recording a choice with rationale |
lesson |
lessons/ |
Something learned from experience |
person |
people/ |
Contact info, relationship context |
commitment |
commitments/ |
Promise made, deliverable owed |
preference |
preferences/ |
How someone likes things done |
fact |
inbox/ |
Raw information to file later |
project |
projects/ |
Workstream with goals and status |
Store with type:
clawvault remember decision "Chose Resend over SendGrid" --content "Lower cost, better DX, webhook support"
clawvault remember lesson "LLMs rewrite keywords during compression" --content "Always post-process with regex"
Rule: If you know WHAT KIND of thing it is, use the right command. Dumping everything into daily notes defeats retrieval later.
2. Task Primitives
A task is a markdown file with YAML frontmatter in tasks/:
---
status: open
priority: high
owner: your-agent-name
project: my-project
due: 2026-03-01
tags: [infrastructure, deploy]
estimate: 2h
---
# Deploy API to production
## Context
Server provisioned. Need Dockerfile fix.
## Next Steps
- Fix binding to 0.0.0.0
- Add health endpoint
- Push and verify
Create tasks:
clawvault task add "Deploy API to production" r
--priority high r
--owner my-agent r
--project my-project r
--due 2026-03-01 r
--tags "infrastructure,deploy"
Update status:
clawvault task update deploy-api-to-production --status in-progress
clawvault task done deploy-api-to-production --reason "Deployed, health check passing"
Statuses: open → in-progress → done (or blocked) Priorities: critical > high > medium > low
3. Project Grouping
Projects group related tasks with metadata:
clawvault project add "Outbound Engine" r
--owner pedro r
--client versatly r
--tags "gtm,sales" r
--deadline 2026-03-15
Tasks reference projects via the project field. Filter tasks by project:
clawvault task list --project outbound-engine
4. Template Schemas
Templates are YAML schema definitions that control what fields exist on every primitive. They live in templates/ in your vault.
See references/template-customization.md for full customization guide.
Key points:
- Vault templates override builtins — drop a
task.mdintemplates/to change the schema - Add fields (e.g.,
sprint,effort,client) by editing the template - Remove fields you don't need
- Change defaults (e.g., default priority =
high) - Validation is advisory — warns but never blocks
5. Heartbeat Loop
The heartbeat is the autonomy mechanism. Wire it into your agent's periodic wake cycle.
Every heartbeat (e.g., every 30 minutes):
1. clawvault task list --owner --status open
2. Sort by: priority (critical first), then due date (soonest first)
3. Pick the highest-impact task executable RIGHT NOW
4. Execute it
5. On completion: clawvault task done --reason "what was done"
6. On blocker: clawvault task update --status blocked --blocked-by "reason"
7. If new work discovered: clawvault task add "new task" --priority --project
8. If lesson learned: clawvault remember lesson "what happened"
9. Go back to sleep
Implementation for OpenClaw agents:
Add to your HEARTBEAT.md:
## Task-Driven Autonomy
Every heartbeat:
1. `clawvault task list --owner --status open` → your work queue
2. Sort by priority + due date
3. Pick highest-impact task you can execute NOW
4. Work it. Update status. Mark done. Report.
5. Check for tasks due within 24h — those get priority
For cron-based agents, schedule a recurring job:
Schedule: every 30 minutes
Action: Read task queue, pick highest priority, execute, report
Composing Primitives into Autonomy
The power is in composition, not any single primitive:
Wake → Read memory → Check tasks → Execute → Learn → Update memory → Sleep
↑ |
└──────────────────────────────────────┘
Each cycle compounds:
- Memory feeds context into task execution (decisions, lessons, preferences inform how work gets done)
- Task execution generates new memories (lessons learned, decisions made, commitments created)
- Lessons improve future execution (mistakes aren't repeated)
- Wiki-links (
[[entity-name]]) build a knowledge graph across all files - Projects provide scope boundaries so the agent doesn't drift
Adapting to Your Setup
See references/adaptation-guide.md for detailed patterns on:
- Wiring primitives into existing agent frameworks (OpenClaw, LangChain, CrewAI, custom)
- Choosing which primitives to adopt (start minimal, add as needed)
- Multi-agent collaboration through shared vaults
- Migrating from other memory systems
Quick Start: Zero to Autonomous in 5 Minutes
# 1. Install and init
npm install -g clawvault
clawvault init
# 2. Create your first project
clawvault project add "My Project" --owner my-agent
# 3. Create tasks
clawvault task add "Set up monitoring" --priority high --owner my-agent --project my-project
clawvault task add "Write API docs" --priority medium --owner my-agent --project my-project
# 4. Wire into heartbeat (add to HEARTBEAT.md or cron)
# "Every 30min: clawvault task list --owner my-agent --status open, pick top task, execute"
# 5. Start working
clawvault task update set-up-monitoring --status in-progress
# ... do the work ...
clawvault task done set-up-monitoring --reason "Prometheus + Grafana configured"
clawvault remember lesson "UptimeRobot free tier only checks every 5min" --content "Use Better Stack for <1min checks"
Anti-Patterns
| Don't | Do Instead |
|---|---|
| Store everything in one big memory file | Use typed memory — decisions/, lessons/, people/ |
| Create tasks without owner/project | Always set --owner and --project |
| Ask "what should I work on?" | Read your task queue and decide |
| Forget lessons after learning them | clawvault remember lesson immediately |
| Skip marking tasks done | Always task done --reason — the ledger tracks transitions |
| Create tasks for vague ideas | Put ideas in backlog/, promote to tasks/ when ready |
| Modify template schemas constantly | Stabilize schemas early — field renames break existing files |
Obsidian Integration
Because everything is markdown + YAML frontmatter, Obsidian renders your agent's workspace as a human-readable dashboard:
- Kanban board — open
all-tasks.basein Obsidian Bases, drag between status columns - Blocked view —
blocked.baseshows what needs human input - By owner —
by-owner.baseshows what each agent is working on - By project —
by-project.basescopes views per workstream
The same file is both the agent's data structure AND the human's UI. No sync layer needed.
相关推荐
专题
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
最新数据
相关文章
Auto Quotation System: 自动化软件项目定价 - Openclaw Skills
AI Vulnerability Tracker:使用 Openclaw Skills 监控 LLM 安全
Q&A Prep Partner: 演讲问题预测器 - Openclaw Skills
NIH Biosketch Builder:自动化 NIH 资助文档生成 - Openclaw Skills
Minecraft 3D 建造计划生成器:AI 场景架构师 - Openclaw Skills
Scholar Search:自动化文献搜索与研究简报 - Openclaw Skills
issue-to-pr: 自动化 GitHub Issue 修复与 PR 生成 - Openclaw Skills
接班交班总结器:临床 EHR 自动化 - Openclaw Skills
Teacher AI 备课专家:K-12 自动化教案设计 - Openclaw Skills
专利权利要求映射器:生物技术与制药 IP 分析 - Openclaw Skills
AI精选
