TaskRepository
public interface TaskRepository
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
字段详情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.
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
rc | RuntimeContext | 当前调用's 运行时上下文;可能为`RuntimeContext#empty()`。the current call's runtime context; may be `RuntimeContext#empty()` |
sessionId | String | 父级会话范围。the parent session scope |
taskId | String | 任务标识(类型 `String`)。unique task identifier |
BackgroundTaskio/agentscope/harness/agent/subagent/task/TaskRepository.java:45putTask
public BackgroundTask putTask(RuntimeContext rc, String taskId, String subAgentId, String sessionId, TaskRunSpec spec)
执行 putTask 方法。
Submit a new background task according to TaskRunSpec.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
rc | RuntimeContext | 当前调用's 运行时上下文;可能为`RuntimeContext#empty()`。the current call's runtime context; may be `RuntimeContext#empty()` |
taskId | String | 任务标识(类型 `String`)。unique identifier for the task |
subAgentId | String | 子智能体标识(类型 `String`)。the subagent type executing this task |
sessionId | String | 父级会话范围。the parent session scope |
spec | TaskRunSpec | 规格(类型 `TaskRunSpec`)。local supplier execution or remote HTTP task protocol |
BackgroundTaskio/agentscope/harness/agent/subagent/task/TaskRepository.java:60–65listTasks
public Collection<BackgroundTask> listTasks(RuntimeContext rc, String sessionId, TaskStatus filter)
列出任务。
List all tracked tasks for the given session, optionally filtered by status.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
rc | RuntimeContext | 当前调用's 运行时上下文;可能为`RuntimeContext#empty()`。the current call's runtime context; may be `RuntimeContext#empty()` |
sessionId | String | 父级会话范围。the parent session scope |
filter | TaskStatus | 过滤条件(类型 `TaskStatus`)。if non-null, only return tasks with this status; null returns all tasks |
Collection<BackgroundTask>io/agentscope/harness/agent/subagent/task/TaskRepository.java:74cancelTask
public boolean cancelTask(RuntimeContext rc, String sessionId, String taskId)
执行取消任务相关操作。
Cancel a running task by session and task ID.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
rc | RuntimeContext | 当前调用's 运行时上下文;可能为`RuntimeContext#empty()`。the current call's runtime context; may be `RuntimeContext#empty()` |
sessionId | String | 会话标识(类型 `String`)。The session id. |
taskId | String | 任务标识(类型 `String`)。The task id. |
booleanio/agentscope/harness/agent/subagent/task/TaskRepository.java:82findPendingDeliveries
default public List<TaskDelivery> findPendingDeliveries(RuntimeContext rc, String sessionId)
查找 findPendingDeliveries。
Returns terminal-state tasks for the given session whose completions have not yet been pushed back to the parent agent.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
rc | RuntimeContext | rc(类型 `RuntimeContext`)。The rc. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
List<TaskDelivery>io/agentscope/harness/agent/subagent/task/TaskRepository.java:103–105markDelivered
default public void markDelivered(RuntimeContext rc, String sessionId, String taskId)
执行 markDelivered 方法。
Stamps the given task as delivered so it does not get pushed again.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
rc | RuntimeContext | rc(类型 `RuntimeContext`)。The rc. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
taskId | String | 任务标识(类型 `String`)。The task id. |
io/agentscope/harness/agent/subagent/task/TaskRepository.java:113–115isDelivered
default public boolean isDelivered(RuntimeContext rc, String sessionId, String taskId)
判断是否 isDelivered。
Whether the given task has already been delivered to the parent agent.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
rc | RuntimeContext | rc(类型 `RuntimeContext`)。The rc. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
taskId | String | 任务标识(类型 `String`)。The task id. |
booleanio/agentscope/harness/agent/subagent/task/TaskRepository.java:124–126setCompletionCallback
default public void setCompletionCallback(TaskCompletionCallback callback)
设置补全回调。
Registers a callback invoked when any task reaches a terminal state (COMPLETED or FAILED).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
callback | TaskCompletionCallback | 回调函数(类型 `TaskCompletionCallback`)。The callback. |
io/agentscope/harness/agent/subagent/task/TaskRepository.java:139–141shutdown
default public void shutdown()
关闭资源并释放连接。
Shuts down background executors owned by this repository.
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.