AS AgentScopeAPI 手册 / API Reference

ScheduleAgentTask

public interface ScheduleAgentTask<T>
源码Source 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.

返回Returns String
返回字符串结果。The unique task identifier
源码Source io/agentscope/extensions/scheduler/ScheduleAgentTask.java:72

getName

public String getName()

获取名称的此已调度任务。

Get the name of this scheduled task.

返回Returns String
任务名称。The task name
源码Source io/agentscope/extensions/scheduler/ScheduleAgentTask.java:83

run

public Mono<T> run(Msg... msgs)

设置运行。

Execute the scheduled task immediately.

参数Parameters
名称Name类型Type说明Description
msgs varargsMsg...消息列表(类型 `Msg...`)。The input messages to pass to the agent (optional, can be empty)
返回Returns Mono<T>
返回Mono。A Mono that emits the agent's response message when execution completes
抛出Throws
  • IllegalStateException 可能抛出 `IllegalStateException`。if the task has been cancelled
  • RuntimeException 可能抛出 `RuntimeException`。if the execution fails
源码Source io/agentscope/extensions/scheduler/ScheduleAgentTask.java:105

cancel

public void cancel()

执行取消相关操作。

Cancel this scheduled task permanently.

源码Source io/agentscope/extensions/scheduler/ScheduleAgentTask.java:123
基于官方固定版本源码静态生成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.