ScheduleAgentTask
public interface ScheduleAgentTask<T>
io/agentscope/extensions/scheduler/ScheduleAgentTask.java:61–124定义调度智能体任务契约的接口。位于 io.agentscope.extensions.scheduler 包。核心成员包括 getId、getName、run、cancel。
Interface representing a scheduled agent task.
This interface defines the core operations for managing and controlling scheduled agent tasks. It provides a clean separation between task scheduling concerns and agent execution logic.
Design Principles:
-
Single Responsibility - Focuses solely on task lifecycle management
-
Interface Segregation - Minimal interface with only essential operations
-
Framework Agnostic - Can be implemented with any scheduling backend
Usage Example:
`// Schedule an agent task
AgentConfig config = AgentConfig.builder()
.name("MyAgent")
.model(myModel)
.build();
ScheduleAgentTask task = scheduler.schedule(config, scheduleConfig);
// Control the task
String taskId = task.getId();
String taskName = task.getName();
// Manually trigger execution
task.run();
// Cancel the task
task.cancel();
`
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String getId() | 获取标识。 Get the unique identifier of this scheduled task. |
public String getName() | 获取名称的此已调度任务。 Get the name of this scheduled task. |
public Mono<T> run(Msg... msgs) | 设置运行。 Execute the scheduled task immediately. |
public void cancel() | 执行取消相关操作。 Cancel this scheduled task permanently. |
方法详情Method Detail
getId
public String getId()
获取标识。
Get the unique identifier of this scheduled task.
Stringio/agentscope/extensions/scheduler/ScheduleAgentTask.java:72getName
public String getName()
获取名称的此已调度任务。
Get the name of this scheduled task.
Stringio/agentscope/extensions/scheduler/ScheduleAgentTask.java:83run
public Mono<T> run(Msg... msgs)
设置运行。
Execute the scheduled task immediately.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msgs varargs | Msg... | 消息列表(类型 `Msg...`)。The input messages to pass to the agent (optional, can be empty) |
Mono<T>IllegalStateException可能抛出 `IllegalStateException`。if the task has been cancelledRuntimeException可能抛出 `RuntimeException`。if the execution fails
io/agentscope/extensions/scheduler/ScheduleAgentTask.java:105cancel
public void cancel()
执行取消相关操作。
Cancel this scheduled task permanently.
io/agentscope/extensions/scheduler/ScheduleAgentTask.java:123