AS AgentScopeAPI 手册 / API Reference

TaskRepository

public interface TaskRepository
源码Source io/agentscope/harness/agent/subagent/task/TaskRepository.java:33–161

定义任务仓库契约的接口。位于 io.agentscope.harness.agent.subagent.task 包。核心成员包括 getTask、putTask、listTasks、cancelTask、findPendingDeliveries、markDelivered。

Repository for managing background subagent tasks, scoped by session.

All operations are scoped to a sessionId so that tasks from different parent sessions are isolated from one another. Implementations may ignore sessionId (in-memory stores) or use it to partition durable storage (workspace-backed stores).

Every method accepts a RuntimeContext: implementations that persist task state through a per-user namespaced filesystem must propagate rc so that writes from concurrent users land in their respective namespaces.

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
TaskCompletionCallback接口interface
定义任务补全回调契约的接口。
Callback invoked when a background task reaches a terminal state (COMPLETED or FAILED).

字段摘要Field Summary

字段Field类型Type说明Description
SUPPRESS_COMPLETION_CALLBACK
String
SUPPRESS 补全回调字段。
RuntimeContext flag for callers that retain execution ownership and collect results themselves.

方法摘要Method Summary

方法Method说明Description
public BackgroundTask getTask(RuntimeContext rc, String sessionId, String taskId)
获取任务。
Retrieve a background task by session and task ID, or `null` if not found.
public BackgroundTask putTask(RuntimeContext rc, String taskId, String subAgentId, String sessionId, TaskRunSpec spec)
执行 `putTask` 方法。
Submit a new background task according to `TaskRunSpec`.
public Collection<BackgroundTask> listTasks(RuntimeContext rc, String sessionId, TaskStatus filter)
列出任务。
List all tracked tasks for the given session, optionally filtered by status.
public boolean cancelTask(RuntimeContext rc, String sessionId, String taskId)
执行取消任务相关操作。
Cancel a running task by session and task ID.
default public List<TaskDelivery> findPendingDeliveries(RuntimeContext rc, String sessionId)
default
查找 `findPendingDeliveries`。
Returns terminal-state tasks for the given session whose completions have not yet been pushed back to the parent agent.
default public void markDelivered(RuntimeContext rc, String sessionId, String taskId)
default
执行 `markDelivered` 方法。
Stamps the given task as delivered so it does not get pushed again.
default public boolean isDelivered(RuntimeContext rc, String sessionId, String taskId)
default
判断是否 `isDelivered`。
Whether the given task has already been delivered to the parent agent.
default public void setCompletionCallback(TaskCompletionCallback callback)
default
设置补全回调。
Registers a callback invoked when any task reaches a terminal state (COMPLETED or FAILED).
default public void shutdown()
default
关闭资源并释放连接。
Shuts down background executors owned by this repository.

字段详情Field Detail

SUPPRESS_COMPLETION_CALLBACK

String SUPPRESS_COMPLETION_CALLBACK

SUPPRESS 补全回调字段。声明为 String SUPPRESS_COMPLETION_CALLBACK。

RuntimeContext flag for callers that retain execution ownership and collect results themselves.

源码Source io/agentscope/harness/agent/subagent/task/TaskRepository.java:36

方法详情Method Detail

getTask

public BackgroundTask getTask(RuntimeContext rc, String sessionId, String taskId)

获取任务。

Retrieve a background task by session and task ID, or null if not found.

参数Parameters
名称Name类型Type说明Description
rcRuntimeContext当前调用's 运行时上下文;可能为`RuntimeContext#empty()`。the current call's runtime context; may be `RuntimeContext#empty()`
sessionIdString父级会话范围。the parent session scope
taskIdString任务标识(类型 `String`)。unique task identifier
返回Returns BackgroundTask
返回BackgroundTask。Returns background task.
源码Source io/agentscope/harness/agent/subagent/task/TaskRepository.java:45

putTask

public BackgroundTask putTask(RuntimeContext rc, String taskId, String subAgentId, String sessionId, TaskRunSpec spec)

执行 putTask 方法。

Submit a new background task according to TaskRunSpec.

参数Parameters
名称Name类型Type说明Description
rcRuntimeContext当前调用's 运行时上下文;可能为`RuntimeContext#empty()`。the current call's runtime context; may be `RuntimeContext#empty()`
taskIdString任务标识(类型 `String`)。unique identifier for the task
subAgentIdString子智能体标识(类型 `String`)。the subagent type executing this task
sessionIdString父级会话范围。the parent session scope
specTaskRunSpec规格(类型 `TaskRunSpec`)。local supplier execution or remote HTTP task protocol
返回Returns BackgroundTask
返回BackgroundTask。the created background task
源码Source io/agentscope/harness/agent/subagent/task/TaskRepository.java:60–65

listTasks

public Collection<BackgroundTask> listTasks(RuntimeContext rc, String sessionId, TaskStatus filter)

列出任务。

List all tracked tasks for the given session, optionally filtered by status.

参数Parameters
名称Name类型Type说明Description
rcRuntimeContext当前调用's 运行时上下文;可能为`RuntimeContext#empty()`。the current call's runtime context; may be `RuntimeContext#empty()`
sessionIdString父级会话范围。the parent session scope
filterTaskStatus过滤条件(类型 `TaskStatus`)。if non-null, only return tasks with this status; null returns all tasks
返回Returns Collection<BackgroundTask>
返回集合。Returns collection.
源码Source io/agentscope/harness/agent/subagent/task/TaskRepository.java:74

cancelTask

public boolean cancelTask(RuntimeContext rc, String sessionId, String taskId)

执行取消任务相关操作。

Cancel a running task by session and task ID.

参数Parameters
名称Name类型Type说明Description
rcRuntimeContext当前调用's 运行时上下文;可能为`RuntimeContext#empty()`。the current call's runtime context; may be `RuntimeContext#empty()`
sessionIdString会话标识(类型 `String`)。The session id.
taskIdString任务标识(类型 `String`)。The task id.
返回Returns boolean
返回布尔值,表示判断结果。true if the task was found and cancellation was attempted
源码Source io/agentscope/harness/agent/subagent/task/TaskRepository.java:82

findPendingDeliveries

default public List<TaskDelivery> findPendingDeliveries(RuntimeContext rc, String sessionId)
default

查找 findPendingDeliveries。

Returns terminal-state tasks for the given session whose completions have not yet been pushed back to the parent agent.

参数Parameters
名称Name类型Type说明Description
rcRuntimeContextrc(类型 `RuntimeContext`)。The rc.
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns List<TaskDelivery>
返回列出。Returns list.
源码Source io/agentscope/harness/agent/subagent/task/TaskRepository.java:103–105

markDelivered

default public void markDelivered(RuntimeContext rc, String sessionId, String taskId)
default

执行 markDelivered 方法。

Stamps the given task as delivered so it does not get pushed again.

参数Parameters
名称Name类型Type说明Description
rcRuntimeContextrc(类型 `RuntimeContext`)。The rc.
sessionIdString会话标识(类型 `String`)。The session id.
taskIdString任务标识(类型 `String`)。The task id.
源码Source io/agentscope/harness/agent/subagent/task/TaskRepository.java:113–115

isDelivered

default public boolean isDelivered(RuntimeContext rc, String sessionId, String taskId)
default

判断是否 isDelivered。

Whether the given task has already been delivered to the parent agent.

参数Parameters
名称Name类型Type说明Description
rcRuntimeContextrc(类型 `RuntimeContext`)。The rc.
sessionIdString会话标识(类型 `String`)。The session id.
taskIdString任务标识(类型 `String`)。The task id.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/harness/agent/subagent/task/TaskRepository.java:124–126

setCompletionCallback

default public void setCompletionCallback(TaskCompletionCallback callback)
default

设置补全回调。

Registers a callback invoked when any task reaches a terminal state (COMPLETED or FAILED).

参数Parameters
名称Name类型Type说明Description
callbackTaskCompletionCallback回调函数(类型 `TaskCompletionCallback`)。The callback.
源码Source io/agentscope/harness/agent/subagent/task/TaskRepository.java:139–141

shutdown

default public void shutdown()
default

关闭资源并释放连接。

Shuts down background executors owned by this repository.

源码Source io/agentscope/harness/agent/subagent/task/TaskRepository.java:144–146

嵌套类详情Nested Class Detail

TaskCompletionCallback

@FunctionalInterface interface TaskCompletionCallback

定义任务补全回调契约的接口。位于 io.agentscope.harness.agent.subagent.task 包。核心成员包括 onCompleted。

Callback invoked when a background task reaches a terminal state (COMPLETED or FAILED). result is null when the task failed.

基于官方固定版本源码静态生成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.