首页 理论 架构 工程 文档 白皮书 著作 研究 案例 下载 博客 关于 开始使用 →

第54章 Action

第54章 Action

本章大纲

  1. Action 定义
  2. Action 参数
  3. Action 执行
  4. Action 状态
  5. Action Result
  6. Action Executor
  7. Action 示例

1. Action 定义

Action(行动)是 ICAI 在形成 Decision、确定 Behavior 之后,对具体目标执行具体方法的实际操作单元

前一章中:

Decision = 决定做什么
Behavior = 执行行为
Action = 行为中的具体操作

因此可以进一步细化:

Reasoning
    ↓
Decision
    ↓
Choice
    ↓
Behavior
    ↓
Action
    ↓
Result

例如:

Decision:
选择 Service_A

Behavior:
执行服务申请行为

Action:
create_delivery_request()

Result:
request_created

所以:

Action 是 ICAI 可被执行、可被管理、可产生结果的具体行动单元。


1.1 Action 与 Behavior 的区别

Behavior 是较大的行为过程,Action 是其中具体可执行的操作。

例如:

Behavior:
处理家具送货请求

可以包含:

Action_001 → 检查服务
Action_002 → 创建请求
Action_003 → 保存请求
Action_004 → 返回结果

因此:

Behavior
 ├── Action
 ├── Action
 └── Action

也可以存在一个简单 Behavior 只包含一个 Action:

Behavior
    ↓
Action

1.2 Action 的基本结构

Action
{
    id
    type
    target
    method
    parameters
    condition
    state
    result
}

例如:

Action
{
    id: 6001,
    type: "CREATE",
    target: "DeliveryRequest",
    method: "create",
    parameters: {
        origin: "Shenzhen",
        destination: "HongKong",
        object: "Furniture"
    },
    condition: "Service_A.available",
    state: "READY",
    result: null
}

2. Action 参数

Action Parameter 是执行具体 Action 所需要的数据。

例如:

create_delivery_request(
    origin,
    destination,
    object
)

其中:

origin
destination
object

就是 Action 参数。


2.1 参数结构

可以定义:

ActionParameter
{
    name
    value
    type
    required
    default
    state
}

例如:

ActionParameter
{
    name: "origin",
    value: "Shenzhen",
    type: "string",
    required: true,
    default: null,
    state: "VALID"
}

2.2 参数类型

Action 参数可以包括:

STRING
INTEGER
FLOAT
BOOLEAN
DATE
TIME
DATETIME
OBJECT
ARRAY

也可以根据 ICAI 的实际能力增加:

LOCATION
RANGE
ENUM
RELATION
STATE

2.3 参数验证

Action 执行前必须检查参数。

例如:

origin = Shenzhen
destination = HongKong
object = Furniture

系统检查:

origin 是否存在?
destination 是否存在?
object 是否存在?
类型是否正确?
参数是否完整?
参数之间是否冲突?

如果全部通过:

ParameterValidation = TRUE

否则:

ParameterValidation = FALSE

因此:

Action
    ↓
Parameter Validation
    ↓
Condition Check
    ↓
Execution

3. Action 执行

Action Execution 是把已经确定的 Action 交给对应执行机制实际处理。

基本流程:

Action
    ↓
Validate
    ↓
Prepare
    ↓
Execute
    ↓
Result

3.1 Validate

首先检查:

Action 是否存在?
Target 是否存在?
Method 是否存在?
Parameters 是否完整?
Condition 是否满足?
Capability 是否具备?
Risk 是否允许?

例如:

Action.target = Service_A
Action.method = create_delivery_request

如果 Service_A 不存在:

Action.state = FAILED

如果方法不存在:

Action.state = FAILED

3.2 Prepare

验证成功以后,进入准备阶段:

READY

准备包括:

加载目标
加载方法
准备参数
检查执行条件
建立执行上下文

3.3 Execute

准备完成:

READY
   ↓
RUNNING
   ↓
Execute Method

例如:

create_delivery_request()

执行以后产生:

ActionResult

3.4 执行不是决策

Action 执行阶段不应该重新进行 Decision。

正确关系:

Decision
    ↓
Choice
    ↓
Behavior
    ↓
Action
    ↓
Execute

如果 Action 执行过程中发现新的重要信息,则可以停止当前 Action,重新进入认知循环:

Action
 ↓
New Information
 ↓
Perception
 ↓
Cognition
 ↓
Reasoning
 ↓
Decision

这属于 ICAI 的反馈循环,而不是 Action 自己承担 Decision。


4. Action 状态

Action State 描述具体 Action 当前处于什么状态。

可以定义:

NEW
READY
RUNNING
WAITING
SUCCESS
FAILED
CANCELLED
TIMEOUT
CONFLICT
UNKNOWN

4.1 NEW

Action 已创建,但尚未验证。

state = NEW

4.2 READY

Action 已经通过参数、条件和执行能力检查。

state = READY

4.3 RUNNING

Action 正在执行。

state = RUNNING

4.4 WAITING

Action 暂时不能继续。

例如:

等待目标
等待时间
等待资源
等待外部结果
等待条件

状态:

state = WAITING

4.5 SUCCESS

Action 成功完成:

state = SUCCESS

4.6 FAILED

Action 执行失败:

state = FAILED

4.7 CANCELLED

Action 被取消:

state = CANCELLED

4.8 TIMEOUT

超过执行时间:

state = TIMEOUT

4.9 CONFLICT

执行过程中出现不可直接解决的冲突:

state = CONFLICT

4.10 UNKNOWN

系统无法确定 Action 的最终执行状态:

state = UNKNOWN

因此 Action 生命周期可以表示为:

NEW
 ↓
READY
 ↓
RUNNING
 ↓
SUCCESS

异常路径:

RUNNING
 ├── WAITING
 ├── FAILED
 ├── CANCELLED
 ├── TIMEOUT
 ├── CONFLICT
 └── UNKNOWN

需要区分:

Action State
Behavior State
Object State
Memory State

它们不是同一个状态体系。

例如:

Action.state = RUNNING
Object.state = ACTIVE
Memory.state = UPDATED

三个状态可以同时成立。


5. Action Result

Action Result 是 Action 执行以后产生的结构化结果。

基本结构:

ActionResult
{
    action_id
    state
    output
    changes
    error
    message
    started_at
    completed_at
}

例如:

ActionResult
{
    action_id: 6001,
    state: "SUCCESS",

    output: {
        request_id: "REQ001"
    },

    changes: {
        request_state: "created"
    },

    error: null,

    started_at: "2026-09-12 18:00:00",
    completed_at: "2026-09-12 18:00:01"
}

5.1 Output

Output 是 Action 产生的输出数据。

例如:

output:
{
    request_id: "REQ001"
}

5.2 Changes

Changes 表示 Action 对系统或对象产生的变化。

例如:

changes:
{
    DeliveryRequest.state: "created"
}

这非常重要,因为 ICAI 不仅需要知道:

Action 做了什么?

还需要知道:

Action 改变了什么?

5.3 Error

如果 Action 失败:

ActionResult
{
    state: "FAILED",
    error: "target_unavailable"
}

失败结果也应该保存。

因为:

失败结果
   ↓
Feedback
   ↓
Experience
   ↓
Learning

失败不是没有数据,而是重要的经验来源。


6. Action Executor

Action Executor 是负责实际执行 Action 的执行机制。

它与 Action 的关系:

Action = 描述要执行什么
ActionExecutor = 实际执行 Action

因此:

Action
    ↓
ActionExecutor
    ↓
Method
    ↓
Execution
    ↓
ActionResult

6.1 ActionExecutor 基本方法

可以定义:

ActionExecutor
{
    validate()
    prepare()
    execute()
    handleResult()
    handleError()
    cancel()
}

6.2 validate()

检查 Action:

validate(Action)

主要检查:

Action ID
Target
Method
Parameters
Condition
State

结果:

TRUE
FALSE

6.3 prepare()

准备执行环境:

prepare(Action)

包括:

加载 Target
加载 Method
整理 Parameters
建立 Context

6.4 execute()

执行 Action:

execute(Action)

基本过程:

Action
 ↓
Method
 ↓
Parameters
 ↓
Execution
 ↓
Output

6.5 handleResult()

处理执行结果:

handleResult(ActionResult)

例如:

SUCCESS
FAILED
WAITING
TIMEOUT
CONFLICT
UNKNOWN

6.6 handleError()

如果执行出现异常:

handleError()

系统可以:

记录错误
更新 Action 状态
停止 Action
重试
转入诊断
产生反馈

是否重试不能由 Executor 随意决定。

可以由:

Rule
Risk
Decision

共同决定。


6.7 ActionExecutor 与 BehaviorManager

上一章的 BehaviorManager 管理整个 Behavior。

本章的 ActionExecutor 负责具体 Action。

因此:

BehaviorManager
       ↓
Behavior
       ↓
Action
       ↓
ActionExecutor
       ↓
Method
       ↓
Result

可以形成明确的层级:

Decision
   ↓
BehaviorManager
   ↓
Behavior
   ↓
ActionExecutor
   ↓
Action
   ↓
Execution
   ↓
ActionResult

7. Action 示例

继续使用:

深圳 → 香港
家具 → 送货上门

经过:

Perception
 ↓
Cognition
 ↓
Understanding
 ↓
Reasoning
 ↓
Decision
 ↓
Priority
 ↓
Choice
 ↓
Behavior

得到:

Choice = Service_A

Behavior:

Behavior
{
    id: 5001,
    type: "SERVICE_REQUEST",
    target: "Service_A",
    state: "READY"
}

Behavior 中包含具体 Action:

Action_001
    检查服务

Action_002
    创建配送请求

Action_003
    保存请求

Action_004
    返回结果

7.1 Action_001:检查服务

Action
{
    id: 6001,
    type: "QUERY",
    target: "Service_A",
    method: "checkAvailability",
    parameters: {},
    state: "READY"
}

执行:

ActionExecutor
    ↓
checkAvailability()

结果:

ActionResult
{
    action_id: 6001,
    state: "SUCCESS",
    output: {
        available: true
    }
}

7.2 Action_002:创建请求

Action
{
    id: 6002,

    type: "CREATE",

    target: "DeliveryRequest",

    method: "create",

    parameters:
    {
        origin: "Shenzhen",
        destination: "HongKong",
        object: "Furniture",
        service: "DoorToDoor"
    },

    state: "READY"
}

执行:

ActionExecutor
    ↓
create()

得到:

ActionResult
{
    action_id: 6002,
    state: "SUCCESS",

    output:
    {
        request_id: "REQ001"
    },

    changes:
    {
        request_state: "created"
    }
}

7.3 Action_003:保存

Action
{
    id: 6003,
    type: "UPDATE",
    target: "DeliveryRequest",
    method: "save",
    parameters:
    {
        request_id: "REQ001"
    },
    state: "READY"
}

执行成功:

ActionResult.state = SUCCESS

7.4 Action_004:返回结果

最后一个 Action:

Action
{
    id: 6004,
    type: "COMMUNICATE",
    target: "CurrentUser",
    method: "returnResult",
    parameters:
    {
        request_id: "REQ001",
        state: "created"
    },
    state: "READY"
}

执行以后:

ActionResult
    ↓
SUCCESS

整个 Behavior 完成:

Behavior.state = SUCCESS

Action 完整执行模型

Decision
    ↓
Choice
    ↓
Behavior
    ↓
Action
    ↓
Parameter Validation
    ↓
Condition Check
    ↓
Capability Check
    ↓
Risk Check
    ↓
ActionExecutor
    ↓
Method
    ↓
Execution
    ↓
ActionResult
    ↓
Behavior Result
    ↓
Feedback
    ↓
Experience
    ↓
Learning

Action 与 ICAI 核心链

到第54章,可以把前面的结构进一步明确:

Information
    ↓
Perception
    ↓
Cognition
    ↓
Understanding
    ↓
Reasoning
    ↓
Conclusion
    ↓
Decision
    ↓
Priority
    ↓
Choice
    ↓
Behavior
    ↓
Action
    ↓
Execution
    ↓
Result
    ↓
Experience
    ↓
Learning
    ↓
Memory Update

其中:

Decision = 选择
Priority = 排序
Behavior = 行为组织
Action = 具体行动
Executor = 行动执行
Result = 执行结果

Action 核心定义

Action 是 ICAI 在确定 Behavior 后,对指定目标调用指定方法,并按照规定参数和执行条件完成具体操作的基本行动单元。

最终形成:

Behavior
    ↓
Action
    ↓
Executor
    ↓
Method
    ↓
Result

这也使 Behavior 与 Action 有了清晰的层次:

Behavior = 我正在进行什么行为
Action   = 这个行为现在具体做什么
Method   = 具体通过什么方法完成
Executor = 谁负责执行这个方法
Result   = 最终产生什么结果

这样,第53章的 Behavior 与第54章的 Action 就不会重复:Behavior 是行为层,Action 是执行层的具体行动单元。

Leave a Reply

Your email address will not be published. Required fields are marked *