AgentProtocolTaskStore
public final class AgentProtocolTaskStore
io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:66–648智能体协议任务存储,负责持久化与读取数据。位于 io.agentscope.extensions.agentprotocol 包。核心成员包括 eventBus、submit、resume、snapshot、waitFor、cancel。
In-memory execution handles with control-plane TaskRecord persistence.
Each run resolves its HarnessAgent through the AgentFactory, which receives
the submission context and can therefore route per task. For concurrent task execution, return a
new instance per call (e.g. a Spring prototype-scoped bean); a shared instance requires the agent
to be configured with checkRunning(false).
Task metadata is stored via ProtocolTaskRepository (a dedicated control-plane path),
not via any execution agent's workspace. Caller-supplied context.attributes reach the
run through its RuntimeContext; see RuntimeContextCustomizer for controlling how.
构造器摘要Constructor Summary
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public AgentProtocolEventBus eventBus() | 返回事件总线。 Returns the event bus. |
public void submit(String taskId, String agentId, String input) | 执行提交相关操作。 Starts a background task. |
public void submit(String taskId, String agentId, String input, Map<String, Object> context) | 执行提交相关操作。 Performs the submit operation. |
public void resume(String taskId, List<RemoteConfirmDecision> decisions) | 执行恢复相关操作。 Resumes a task paused for HITL confirmation with the given decisions. |
public Map<String, Object> snapshot(String taskId) | 设置快照。 Performs the snapshot operation. |
public Map<String, Object> waitFor(String taskId, long timeoutMs) throws Exception | 等待用于。 Blocks until the task reaches a terminal state or the timeout elapses. |
public void cancel(String taskId) | 执行取消相关操作。 Performs the cancel operation. |
构造器详情Constructor Detail
AgentProtocolTaskStore
public AgentProtocolTaskStore(AgentFactory agentFactory, ProtocolTaskRepository taskRepository, AgentProtocolEventBus eventBus, AgentProtocolProperties properties)
初始化 AgentProtocolTaskStore 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agentFactory | AgentFactory | 智能体工厂(类型 `AgentFactory`)。The agent factory. |
taskRepository | ProtocolTaskRepository | 任务仓库(类型 `ProtocolTaskRepository`)。The task repository. |
eventBus | AgentProtocolEventBus | 事件总线(类型 `AgentProtocolEventBus`)。The event bus. |
properties | AgentProtocolProperties | 属性(类型 `AgentProtocolProperties`)。The properties. |
io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:91–97AgentProtocolTaskStore
public AgentProtocolTaskStore(AgentFactory agentFactory, ProtocolTaskRepository taskRepository, AgentProtocolEventBus eventBus, AgentProtocolProperties properties, List<RuntimeContextCustomizer> runtimeContextCustomizers)
初始化 AgentProtocolTaskStore 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agentFactory | AgentFactory | 智能体工厂(类型 `AgentFactory`)。The agent factory. |
taskRepository | ProtocolTaskRepository | 任务仓库(类型 `ProtocolTaskRepository`)。The task repository. |
eventBus | AgentProtocolEventBus | 事件总线(类型 `AgentProtocolEventBus`)。The event bus. |
properties | AgentProtocolProperties | 属性(类型 `AgentProtocolProperties`)。The properties. |
runtimeContextCustomizers | List<RuntimeContextCustomizer> | 运行时上下文 Customizers(类型 `List`)。The runtime context customizers. |
io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:99–113AgentProtocolTaskStore
public AgentProtocolTaskStore(AgentFactory agentFactory, ProtocolTaskRepository taskRepository)
初始化 AgentProtocolTaskStore 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agentFactory | AgentFactory | 智能体工厂(类型 `AgentFactory`)。The agent factory. |
taskRepository | ProtocolTaskRepository | 任务仓库(类型 `ProtocolTaskRepository`)。The task repository. |
io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:115–122AgentProtocolTaskStore
public AgentProtocolTaskStore(HarnessAgent harnessAgent, ProtocolTaskRepository taskRepository)
初始化 AgentProtocolTaskStore 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
harnessAgent | HarnessAgent | Harness 智能体(类型 `HarnessAgent`)。The harness agent. |
taskRepository | ProtocolTaskRepository | 任务仓库(类型 `ProtocolTaskRepository`)。The task repository. |
io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:124–127方法详情Method Detail
eventBus
public AgentProtocolEventBus eventBus()
返回事件总线。
Returns the event bus.
AgentProtocolEventBusio/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:129–131submit
public void submit(String taskId, String agentId, String input)
执行提交相关操作。
Starts a background task.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
taskId | String | 任务标识(类型 `String`)。The task id. |
agentId | String | 智能体标识(类型 `String`)。The agent id. |
input | String | 输入消息(类型 `String`)。The input. |
IllegalStateException可能抛出 `IllegalStateException`。if the task id already completed (HTTP 409)
io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:139–141submit
public void submit(String taskId, String agentId, String input, Map<String, Object> context)
执行提交相关操作。
Performs the submit operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
taskId | String | 任务标识(类型 `String`)。The task id. |
agentId | String | 智能体标识(类型 `String`)。The agent id. |
input | String | 输入消息(类型 `String`)。The input. |
context | Map<String, Object> | 上下文(类型 `Map`)。The context. |
io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:143–171resume
public void resume(String taskId, List<RemoteConfirmDecision> decisions)
执行恢复相关操作。
Resumes a task paused for HITL confirmation with the given decisions.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
taskId | String | 任务标识(类型 `String`)。The task id. |
decisions | List<RemoteConfirmDecision> | decisions(类型 `List`)。The decisions. |
IllegalStateException当if 任务是不等待中的确认时抛出 `IllegalStateException`。if the task is not awaiting confirmation
io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:178–209snapshot
public Map<String, Object> snapshot(String taskId)
设置快照。
Performs the snapshot operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
taskId | String | 任务标识(类型 `String`)。The task id. |
Map<String, Object>io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:445–473waitFor
public Map<String, Object> waitFor(String taskId, long timeoutMs) throws Exception
等待用于。
Blocks until the task reaches a terminal state or the timeout elapses.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
taskId | String | 任务标识(类型 `String`)。The task id. |
timeoutMs | long | 超时 Ms(类型 `long`)。The timeout ms. |
Map<String, Object>Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:479–541cancel
public void cancel(String taskId)
执行取消相关操作。
Performs the cancel operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
taskId | String | 任务标识(类型 `String`)。The task id. |
io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:543–560