OpenClaw工作流程——让龙虾解剖自己
以下是openclaw对自己工作流程和一些细节的解读,博主作为虾佬的interface做了一些简要记录和可视化修饰。
·
以下是openclaw对自己工作流程和一些细节的解读,博主作为虾佬的interface做了一些简要记录和可视化修饰。
知识来源
据虾佬自己透露,它画的跟自身相关的所有图的依据都在源码的 /docs 目录下,不过里面的文档是相对结构化的,虾佬自己整合了一下画了图给我,所以知识来源应该说是比较可靠的。
主干路径

看到网上有很多文章讲解消息机制和gateway的实现,我们主要专注于Agent部分
Agent Loop
处理一条用户消息的核心逻辑:
Intention样式
单一意图举例 - “帮我看看user.md里写了啥”(虾佬给我举的例子)
{
"intent_packet": {
"version": "1.0",
"intent_id": "intent_read_and_summarize_file",
"intent_type": "single",
"primary_intent": "read_and_summarize_file",
"goal": "读取指定文件并向用户总结内容",
"source_message": "帮我看看 USER.md 里写了啥",
"confidence": 0.98,
"planner_mode": "direct_execution",
"requires_tools": true,
"requires_clarification": false,
"context_dependencies": {
"workspace_required": true,
"session_history_required": false,
"memory_required": false
},
"entities": {
"target_path": "USER.md",
"path_resolution": "workspace_relative",
"output_format": "summary"
},
"constraints": {
"read_only": true,
"no_external_side_effects": true
},
"success_criteria": [
"定位到 USER.md",
"成功读取内容",
"向用户返回可理解的摘要"
],
"planner_hints": {
"likely_tools": [
"read"
],
"expected_step_count": 1,
"fallback_if_missing": "report_file_not_found"
}
}
}
复合意图举例 - “写一个检查磁盘占用的脚本,并且每天早上9点执行,异常时通知我”
{
"intent_packet": {
"version": "1.0",
"intent_id": "intent_create_disk_monitor_workflow",
"intent_type": "compound",
"primary_intent": "create_automation_workflow",
"goal": "创建一个可定时运行并带异常通知的磁盘监控自动化",
"source_message": "写一个检查磁盘占用的脚本,并且每天早上9点执行,异常时通知我",
"confidence": 0.94,
"planner_mode": "multi_step_workflow",
"requires_tools": true,
"requires_clarification": "possible",
"context_dependencies": {
"workspace_required": true,
"session_history_required": true,
"memory_required": false
},
"entities": {
"script_purpose": "检查磁盘占用",
"schedule_raw": "每天早上9点",
"timezone": "Asia/Hong_Kong",
"notification_target": "current_session",
"runtime": "unspecified",
"alert_condition": "异常时"
},
"constraints": {
"must_create_new_artifact": true,
"must_bind_schedule_to_created_artifact": true,
"must_support_notification_on_error_or_threshold_breach": true,
"must_ask_if_critical_requirements_are_missing": true
},
"open_questions": [
"脚本语言未指定",
"异常的定义可能需要阈值说明",
"通知内容格式未指定"
],
"sub_intents": [
{
"id": "subintent_create_script",
"intent": "create_script",
"goal": "生成一个用于检查磁盘占用的可执行脚本",
"depends_on": [],
"entities": {
"script_purpose": "检查磁盘占用",
"runtime": "unspecified"
},
"success_criteria": [
"脚本文件被创建",
"脚本能够执行",
"脚本能返回磁盘占用状态"
]
},
{
"id": "subintent_schedule_script",
"intent": "create_scheduled_execution",
"goal": "每天09:00自动运行生成的脚本",
"depends_on": [
"subintent_create_script"
],
"entities": {
"schedule_raw": "每天早上9点",
"timezone": "Asia/Hong_Kong",
"target_ref": "subintent_create_script.output.script_path"
},
"success_criteria": [
"解析出标准调度规则",
"调度目标绑定到新脚本",
"定时任务成功注册"
]
},
{
"id": "subintent_configure_notification",
"intent": "configure_notification",
"goal": "在异常时通知当前用户",
"depends_on": [
"subintent_create_script",
"subintent_schedule_script"
],
"entities": {
"trigger_condition": "异常时",
"delivery_target": "current_session"
},
"success_criteria": [
"异常条件被定义或合理默认",
"通知链路已明确",
"异常发生时能向当前用户发消息"
]
}
],
"success_criteria": [
"生成监控脚本",
"创建每天09:00的定时执行",
"建立异常通知机制"
],
"planner_hints": {
"workflow_shape": "dependency_chain",
"expected_substep_count": 5,
"likely_substeps": [
"resolve_missing_requirements",
"create_script_file",
"derive_execution_command",
"resolve_schedule",
"register_job_and_notification"
],
"likely_tools": [
"write",
"read",
"exec"
],
"parallelizable_sections": [
"schedule_parsing",
"notification_target_resolution"
],
"non_parallelizable_sections": [
"schedule registration depends on script creation"
],
"failure_modes": [
"insufficient_requirements",
"script_creation_failed",
"schedule_registration_failed",
"notification_binding_failed"
]
}
}
}
plan样式
{
"plan_id": "plan_read_user_md_001",
"source_intent_id": "intent_read_and_summarize_file",
"plan_type": "direct_execution",
"goal": "读取 workspace 中的 USER.md 并向用户总结其主要内容",
"status": "ready",
"requires_clarification": false,
"assumptions": [
"USER.md 指的是 workspace 根目录下的 USER.md",
"用户想要摘要而不是逐字全文转发",
"当前环境允许读取该文件"
],
"success_criteria": [
"成功定位 USER.md",
"成功读取文件内容",
"向用户输出简洁可理解的总结"
],
"failure_conditions": [
"文件不存在",
"文件无法读取",
"文件内容为空且无法形成有效总结"
],
"steps": [
{
"step_id": "step_1_read_file",
"title": "读取 USER.md",
"kind": "tool_call",
"description": "从 workspace 根目录读取 USER.md 的内容",
"depends_on": [],
"input": {
"target_path": "USER.md",
"path_resolution": "workspace_relative"
},
"tool": {
"name": "read",
"args": {
"file_path": "C:\\.openclaw\\workspace\\USER.md"
}
},
"expected_output": {
"type": "file_content",
"fields": [
"content"
]
},
"on_success": "step_2_summarize",
"on_failure": "fail",
"notes": [
"如果文件不存在,应返回 file_not_found 错误",
"如果文件较长,可只总结关键字段"
]
},
{
"step_id": "step_2_summarize",
"title": "总结 USER.md 内容",
"kind": "summarize",
"description": "提取 USER.md 的关键信息并生成用户可读摘要",
"depends_on": [
"step_1_read_file"
],
"input": {
"source_ref": "step_1_read_file.output.content",
"summary_style": "concise",
"focus": [
"用户姓名",
"称呼偏好",
"时区",
"重要备注",
"工作/权限相关信息"
]
},
"expected_output": {
"type": "summary_text",
"fields": [
"summary"
]
},
"on_success": "complete",
"on_failure": "fail",
"notes": [
"优先提取结构化字段",
"保留对用户最有帮助的信息",
"避免无意义逐行复述"
]
}
],
"final_output": {
"mode": "summary",
"audience": "user",
"format_notes": [
"用自然语言输出",
"先给总结,再补关键点",
"不需要暴露内部 step_id"
]
}
}
对不同模型的统一输出约束
TBC
memory机制
TBC
更多推荐


所有评论(0)