TaskTool
public class TaskTool
io/agentscope/harness/agent/tool/TaskTool.java:42–252任务工具,封装可被智能体调用的能力。位于 io.agentscope.harness.agent.tool 包。核心成员包括 taskOutput、taskCancel、taskList、TaskTool。
Unified tool for background task lifecycle management. Combines task result retrieval, cancellation, and listing into a single tool class.
-
task_output— retrieve result (blocking or non-blocking) -
task_cancel— cancel a running task -
task_list— list all tracked tasks with optional status filter
All operations are scoped to the current parent session ID via RuntimeContext. The
TaskRepository handles fallback to workspace-persisted records when no local future
exists (cross-node or post-restart scenarios).
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public TaskTool(TaskRepository taskRepository) | 初始化 `TaskTool` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String taskOutput(RuntimeContext runtimeContext, String taskId, Boolean block, Long timeout) | 执行任务输出相关操作。 Performs the task output operation. |
public String taskCancel(RuntimeContext runtimeContext, String taskId) | 执行任务取消相关操作。 Performs the task cancel operation. |
public String taskList(RuntimeContext runtimeContext, String statusFilter) | 执行任务列表相关操作。 Performs the task list operation. |
构造器详情Constructor Detail
TaskTool
public TaskTool(TaskRepository taskRepository)
初始化 TaskTool 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
taskRepository | TaskRepository | 任务仓库(类型 `TaskRepository`)。The task repository. |
io/agentscope/harness/agent/tool/TaskTool.java:49–51方法详情Method Detail
taskOutput
public String taskOutput(RuntimeContext runtimeContext, String taskId, Boolean block, Long timeout)
执行任务输出相关操作。
Performs the task output operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
taskId | String | 任务标识(类型 `String`)。The task id. |
block | Boolean | 内容块(类型 `Boolean`)。The block. |
timeout | Long | 超时时间(类型 `Long`)。The timeout. |
Stringio/agentscope/harness/agent/tool/TaskTool.java:53–140taskCancel
public String taskCancel(RuntimeContext runtimeContext, String taskId)
执行任务取消相关操作。
Performs the task cancel operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
taskId | String | 任务标识(类型 `String`)。The task id. |
Stringio/agentscope/harness/agent/tool/TaskTool.java:142–172taskList
public String taskList(RuntimeContext runtimeContext, String statusFilter)
执行任务列表相关操作。
Performs the task list operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
statusFilter | String | 状态过滤器(类型 `String`)。The status filter. |
Stringio/agentscope/harness/agent/tool/TaskTool.java:174–215