Interface TaskRepository
- All Known Implementing Classes:
WorkspaceTaskRepository
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
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceCallback invoked when a background task reaches a terminal state (COMPLETED or FAILED). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringRuntimeContext flag for callers that retain execution ownership and collect results themselves. -
Method Summary
Modifier and TypeMethodDescriptionbooleancancelTask(io.agentscope.core.agent.RuntimeContext rc, String sessionId, String taskId) Cancel a running task by session and task ID.default List<TaskDelivery>findPendingDeliveries(io.agentscope.core.agent.RuntimeContext rc, String sessionId) Returns terminal-state tasks for the given session whose completions have not yet been pushed back to the parent agent.Retrieve a background task by session and task ID, ornullif not found.default booleanisDelivered(io.agentscope.core.agent.RuntimeContext rc, String sessionId, String taskId) Whether the given task has already been delivered to the parent agent.listTasks(io.agentscope.core.agent.RuntimeContext rc, String sessionId, TaskStatus filter) List all tracked tasks for the given session, optionally filtered by status.default voidmarkDelivered(io.agentscope.core.agent.RuntimeContext rc, String sessionId, String taskId) Stamps the given task as delivered so it does not get pushed again.putTask(io.agentscope.core.agent.RuntimeContext rc, String taskId, String subAgentId, String sessionId, TaskRunSpec spec) Submit a new background task according toTaskRunSpec.default voidRegisters a callback invoked when any task reaches a terminal state (COMPLETED or FAILED).default voidshutdown()Shuts down background executors owned by this repository.
-
Field Details
-
SUPPRESS_COMPLETION_CALLBACK
RuntimeContext flag for callers that retain execution ownership and collect results themselves.- See Also:
-
-
Method Details
-
getTask
Retrieve a background task by session and task ID, ornullif not found.- Parameters:
rc- the current call's runtime context; may beRuntimeContext.empty()sessionId- the parent session scopetaskId- unique task identifier
-
putTask
BackgroundTask putTask(io.agentscope.core.agent.RuntimeContext rc, String taskId, String subAgentId, String sessionId, TaskRunSpec spec) Submit a new background task according toTaskRunSpec.Implementations should capture
rcso that the background execution thread can persist task state under the originating user's namespace.- Parameters:
rc- the current call's runtime context; may beRuntimeContext.empty()taskId- unique identifier for the tasksubAgentId- the subagent type executing this tasksessionId- the parent session scopespec- local supplier execution or remote HTTP task protocol- Returns:
- the created background task
-
listTasks
Collection<BackgroundTask> listTasks(io.agentscope.core.agent.RuntimeContext rc, String sessionId, TaskStatus filter) List all tracked tasks for the given session, optionally filtered by status.- Parameters:
rc- the current call's runtime context; may beRuntimeContext.empty()sessionId- the parent session scopefilter- if non-null, only return tasks with this status; null returns all tasks
-
cancelTask
Cancel a running task by session and task ID.- Parameters:
rc- the current call's runtime context; may beRuntimeContext.empty()- Returns:
- true if the task was found and cancellation was attempted
-
findPendingDeliveries
default List<TaskDelivery> findPendingDeliveries(io.agentscope.core.agent.RuntimeContext rc, String sessionId) Returns terminal-state tasks for the given session whose completions have not yet been pushed back to the parent agent.Implementations should order the result deterministically (typically by completion time ascending) so the parent agent sees deliveries in the order they actually happened.
Default returns an empty list — in-memory repositories do not currently support push.
-
markDelivered
default void markDelivered(io.agentscope.core.agent.RuntimeContext rc, String sessionId, String taskId) Stamps the given task as delivered so it does not get pushed again. Idempotent: calling twice has no effect after the first call.Default is a no-op.
-
isDelivered
default boolean isDelivered(io.agentscope.core.agent.RuntimeContext rc, String sessionId, String taskId) Whether the given task has already been delivered to the parent agent. Used bySubagentsMiddleware.buildTaskSummary(io.agentscope.harness.agent.subagent.task.TaskRepository, io.agentscope.core.agent.RuntimeContext)to omit already-delivered terminal tasks from the SYSTEM-prompt summary.Default returns
false. -
setCompletionCallback
Registers a callback invoked when any task reaches a terminal state (COMPLETED or FAILED). Used bySubagentsMiddlewareto push results to the session inbox and enqueue a wakeup signal. Theresultargument isnullfor failed tasks.Callers retaining execution ownership can set
SUPPRESS_COMPLETION_CALLBACKin their RuntimeContext to suppress inbox/wakeup callbacks while preserving durable results. Implementations supporting this callback should honor the flag.Default is a no-op. Implementations that support push delivery should override.
-
shutdown
default void shutdown()Shuts down background executors owned by this repository. Default is a no-op.
-