AS AgentScopeAPI 手册 / API Reference

AgentProtocolTaskStore

public final class AgentProtocolTaskStore
源码Source 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

构造器Constructor说明Description
public AgentProtocolTaskStore(AgentFactory agentFactory, ProtocolTaskRepository taskRepository, AgentProtocolEventBus eventBus, AgentProtocolProperties properties)
初始化 `AgentProtocolTaskStore` 实例。
Creates a new instance.
public AgentProtocolTaskStore(AgentFactory agentFactory, ProtocolTaskRepository taskRepository, AgentProtocolEventBus eventBus, AgentProtocolProperties properties, List<RuntimeContextCustomizer> runtimeContextCustomizers)
初始化 `AgentProtocolTaskStore` 实例。
Creates a new instance.
public AgentProtocolTaskStore(AgentFactory agentFactory, ProtocolTaskRepository taskRepository)
初始化 `AgentProtocolTaskStore` 实例。
Creates a new instance.
public AgentProtocolTaskStore(HarnessAgent harnessAgent, ProtocolTaskRepository taskRepository)
初始化 `AgentProtocolTaskStore` 实例。
Creates a new instance.

方法摘要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.

参数Parameters
名称Name类型Type说明Description
agentFactoryAgentFactory智能体工厂(类型 `AgentFactory`)。The agent factory.
taskRepositoryProtocolTaskRepository任务仓库(类型 `ProtocolTaskRepository`)。The task repository.
eventBusAgentProtocolEventBus事件总线(类型 `AgentProtocolEventBus`)。The event bus.
propertiesAgentProtocolProperties属性(类型 `AgentProtocolProperties`)。The properties.
源码Source io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:91–97

AgentProtocolTaskStore

public AgentProtocolTaskStore(AgentFactory agentFactory, ProtocolTaskRepository taskRepository, AgentProtocolEventBus eventBus, AgentProtocolProperties properties, List<RuntimeContextCustomizer> runtimeContextCustomizers)

初始化 AgentProtocolTaskStore 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
agentFactoryAgentFactory智能体工厂(类型 `AgentFactory`)。The agent factory.
taskRepositoryProtocolTaskRepository任务仓库(类型 `ProtocolTaskRepository`)。The task repository.
eventBusAgentProtocolEventBus事件总线(类型 `AgentProtocolEventBus`)。The event bus.
propertiesAgentProtocolProperties属性(类型 `AgentProtocolProperties`)。The properties.
runtimeContextCustomizersList<RuntimeContextCustomizer>运行时上下文 Customizers(类型 `List`)。The runtime context customizers.
源码Source io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:99–113

AgentProtocolTaskStore

public AgentProtocolTaskStore(AgentFactory agentFactory, ProtocolTaskRepository taskRepository)

初始化 AgentProtocolTaskStore 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
agentFactoryAgentFactory智能体工厂(类型 `AgentFactory`)。The agent factory.
taskRepositoryProtocolTaskRepository任务仓库(类型 `ProtocolTaskRepository`)。The task repository.
源码Source io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:115–122

AgentProtocolTaskStore

public AgentProtocolTaskStore(HarnessAgent harnessAgent, ProtocolTaskRepository taskRepository)

初始化 AgentProtocolTaskStore 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
harnessAgentHarnessAgentHarness 智能体(类型 `HarnessAgent`)。The harness agent.
taskRepositoryProtocolTaskRepository任务仓库(类型 `ProtocolTaskRepository`)。The task repository.
源码Source io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:124–127

方法详情Method Detail

eventBus

public AgentProtocolEventBus eventBus()

返回事件总线。

Returns the event bus.

返回Returns AgentProtocolEventBus
返回AgentProtocolEventBus。Returns agent protocol event bus.
源码Source io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:129–131

submit

public void submit(String taskId, String agentId, String input)

执行提交相关操作。

Starts a background task.

参数Parameters
名称Name类型Type说明Description
taskIdString任务标识(类型 `String`)。The task id.
agentIdString智能体标识(类型 `String`)。The agent id.
inputString输入消息(类型 `String`)。The input.
抛出Throws
  • IllegalStateException 可能抛出 `IllegalStateException`。if the task id already completed (HTTP 409)
源码Source io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:139–141

submit

public void submit(String taskId, String agentId, String input, Map<String, Object> context)

执行提交相关操作。

Performs the submit operation.

参数Parameters
名称Name类型Type说明Description
taskIdString任务标识(类型 `String`)。The task id.
agentIdString智能体标识(类型 `String`)。The agent id.
inputString输入消息(类型 `String`)。The input.
contextMap<String, Object>上下文(类型 `Map`)。The context.
源码Source io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:143–171

resume

public void resume(String taskId, List<RemoteConfirmDecision> decisions)

执行恢复相关操作。

Resumes a task paused for HITL confirmation with the given decisions.

参数Parameters
名称Name类型Type说明Description
taskIdString任务标识(类型 `String`)。The task id.
decisionsList<RemoteConfirmDecision>decisions(类型 `List`)。The decisions.
抛出Throws
  • IllegalStateException 当if 任务是不等待中的确认时抛出 `IllegalStateException`。if the task is not awaiting confirmation
源码Source io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:178–209

snapshot

public Map<String, Object> snapshot(String taskId)

设置快照。

Performs the snapshot operation.

参数Parameters
名称Name类型Type说明Description
taskIdString任务标识(类型 `String`)。The task id.
返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:445–473

waitFor

public Map<String, Object> waitFor(String taskId, long timeoutMs) throws Exception

等待用于。

Blocks until the task reaches a terminal state or the timeout elapses.

参数Parameters
名称Name类型Type说明Description
taskIdString任务标识(类型 `String`)。The task id.
timeoutMslong超时 Ms(类型 `long`)。The timeout ms.
返回Returns Map<String, Object>
返回映射。Returns map.
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:479–541

cancel

public void cancel(String taskId)

执行取消相关操作。

Performs the cancel operation.

参数Parameters
名称Name类型Type说明Description
taskIdString任务标识(类型 `String`)。The task id.
源码Source io/agentscope/extensions/agentprotocol/AgentProtocolTaskStore.java:543–560
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.