Class TaskTool

java.lang.Object
io.agentscope.harness.agent.tool.TaskTool

public class TaskTool extends Object
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 Details

  • Method Details

    • taskOutput

      @Tool(name="task_output", description="Retrieve a background task created by agent_spawn/agent_send or sessions_spawn/sessions_send with timeout_seconds=0. Prefer block=false to check status without waiting. Use block=true only for one specific task you are ready to block on. For several async subagent tasks, prefer wait_async_results(task_ids=...) or wait_async_results(wait_all=true) when you need a barrier. A returned task ID is immediately queryable. not_found is a tracking/scope error, never evidence that work is running.") public String taskOutput(io.agentscope.core.agent.RuntimeContext runtimeContext, @ToolParam(name="task_id",description="The task_id returned by agent_spawn or agent_send when timeout_seconds was 0") String taskId, @ToolParam(name="block",description="Whether to wait for completion (default: true). Prefer false for status checks to avoid blocking.",required=false) Boolean block, @ToolParam(name="timeout",description="Max wait time in milliseconds (default: 30000, max: 600000)",required=false) Long timeout)
    • taskCancel

      @Tool(name="task_cancel", description="Cancel a running background task. Use to stop a task that is no longer needed. Has no effect on already-completed tasks.") public String taskCancel(io.agentscope.core.agent.RuntimeContext runtimeContext, @ToolParam(name="task_id",description="The task_id to cancel") String taskId)
    • taskList

      @Tool(name="task_list", description="List all background tasks for the current session with their current statuses. Reads from durable workspace storage \u2014 always accurate even after conversation compaction or node migration. Optionally filter by status (running, completed, failed, cancelled). Use this to recover task IDs and state after compaction.") public String taskList(io.agentscope.core.agent.RuntimeContext runtimeContext, @ToolParam(name="status_filter",description="Filter by status: running, completed, failed, cancelled, or omit for all tasks",required=false) String statusFilter)