AS AgentScopeAPI 手册 / API Reference

AgentRun

public final class AgentRun<T>
源码Source io/agentscope/core/agent/AgentRun.java:38–141

智能体运行,驱动智能体的推理、工具调用与会话执行。位于 io.agentscope.core.agent 包。核心成员包括 create、runId、status、stream、termination、cancel。

A single-use, lazy execution handle. Register it before subscribing to #stream(). Each handle owns its cancellation and status; it never registers RuntimeContext on an agent. A second subscription is rejected, so one runId can never identify multiple executions. Cancelling a subscription also cancels this handle. Create another handle to retry.

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Status枚举enum
定义状态的枚举。
Execution state.

方法摘要Method Summary

方法Method说明Description
public static T AgentRun<T> create(String agentId, Supplier<? extends Publisher<T>> source)
static
创建并返回实例。
Wrap an agent invocation without starting it.
public String runId()
运行标识。
Stable opaque identifier for this single execution.
public Status status()
返回状态。
Current execution state; a cooperative interrupt may still be RUNNING until observed.
public Flux<T> stream()
返回流。
Subscribe once to start execution.
public Mono<Status> termination()
返回 `termination` 结果。
A replayable terminal-status notification; observing it does not start execution.
public boolean cancel()
返回取消。
Immediately cancel this run's reactive subscription, including a queued run.
public boolean interrupt(Msg message)
请求中断当前执行。
Cooperatively interrupt a running run, or cancel it if it has not started.
public boolean interrupt()
请求中断当前执行。
Cooperatively interrupt without an associated user message.

方法详情Method Detail

create

public static T AgentRun<T> create(String agentId, Supplier<? extends Publisher<T>> source)
static

创建并返回实例。

Wrap an agent invocation without starting it.

参数Parameters
名称Name类型Type说明Description
agentIdString智能体标识(类型 `String`)。The agent id.
sourceSupplier<? extends Publisher<T>>来源(类型 `Supplier >`)。The source.
返回Returns AgentRun<T>
返回AgentRun。Returns agent run.
源码Source io/agentscope/core/agent/AgentRun.java:103–105

runId

public String runId()

运行标识。

Stable opaque identifier for this single execution.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/agent/AgentRun.java:108–110

status

public Status status()

返回状态。

Current execution state; a cooperative interrupt may still be RUNNING until observed.

返回Returns Status
返回状态。Returns status.
源码Source io/agentscope/core/agent/AgentRun.java:113–115

stream

public Flux<T> stream()

返回流。

Subscribe once to start execution.

返回Returns Flux<T>
返回Flux。Returns flux.
源码Source io/agentscope/core/agent/AgentRun.java:118–120

termination

public Mono<Status> termination()

返回 termination 结果。

A replayable terminal-status notification; observing it does not start execution.

返回Returns Mono<Status>
返回Mono。Returns mono.
源码Source io/agentscope/core/agent/AgentRun.java:123–125

cancel

public boolean cancel()

返回取消。

Immediately cancel this run's reactive subscription, including a queued run.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/agent/AgentRun.java:128–130

interrupt

public boolean interrupt(Msg message)

请求中断当前执行。

Cooperatively interrupt a running run, or cancel it if it has not started.

参数Parameters
名称Name类型Type说明Description
messageMsg消息(类型 `Msg`)。The message.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/agent/AgentRun.java:133–135

interrupt

public boolean interrupt()

请求中断当前执行。

Cooperatively interrupt without an associated user message.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/agent/AgentRun.java:138–140

嵌套类详情Nested Class Detail

Status

public enum Status

定义状态的枚举。位于 io.agentscope.core.agent 包。核心成员包括 isTerminal、CREATED、QUEUED、RUNNING、COMPLETED、FAILED。

Execution state. QUEUED includes setup before admission to the core lifecycle.

基于官方固定版本源码静态生成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.