AS AgentScopeAPI 手册 / API Reference

Runner

public class Runner
源码Source io/agentscope/runtime/engine/Runner.java:50–281

运行器,承载智能体的部署、调度与服务化运行。位于 io.agentscope.runtime.engine 包。核心成员包括 init、start、stop、shutdown、streamQuery、isHealthy。

Runner class that proxies calls to AgentAdapter.

It acts as a proxy to AgentAdapter, managing the lifecycle and query processing.

Key responsibilities:

  • Delegate lifecycle methods (init, start, stop, shutdown) to AgentAdapter

  • Process stream queries by delegating to AgentAdapter

  • Manage health status

  • Handle sequence numbers for events

构造器摘要Constructor Summary

构造器Constructor说明Description
public Runner(AgentHandler adapter)
初始化 `Runner` 实例。
Constructor with AgentAdapter.

方法摘要Method Summary

方法Method说明Description
public void init()
初始化 `Runner` 实例。
Initialize the runner by calling the adapter's init method.
public void start()
执行启动相关操作。
Start the runner by calling the adapter's start method.
public void stop()
执行停止相关操作。
Stop the runner by calling the adapter's stop method.
public void shutdown()
关闭资源并释放连接。
Shutdown the runner by calling the adapter's shutdown method.
public Flux<Event> streamQuery(AgentRequest request)
执行查询。
Stream query by delegating to the adapter.
public boolean isHealthy()
判断是否 `isHealthy`。
Check if the runner is healthy.
public AgentHandler getAgent()
获取智能体。
Get the underlying adapter.
public SandboxService getSandboxService()
获取沙箱服务。
Returns the sandbox service.

构造器详情Constructor Detail

Runner

public Runner(AgentHandler adapter)

初始化 Runner 实例。

Constructor with AgentAdapter.

参数Parameters
名称Name类型Type说明Description
adapterAgentHandlerAgentAdapter 实例到代理。the AgentAdapter instance to proxy
源码Source io/agentscope/runtime/engine/Runner.java:62–67

方法详情Method Detail

init

public void init()

初始化 Runner 实例。

Initialize the runner by calling the adapter's init method.

返回Returns
无返回值。a CompletableFuture that completes when initialization is done
源码Source io/agentscope/runtime/engine/Runner.java:74–76

start

public void start()

执行启动相关操作。

Start the runner by calling the adapter's start method.

返回Returns
无返回值。a CompletableFuture that completes when the runner is started
源码Source io/agentscope/runtime/engine/Runner.java:85–89

stop

public void stop()

执行停止相关操作。

Stop the runner by calling the adapter's stop method.

源码Source io/agentscope/runtime/engine/Runner.java:94–98

shutdown

public void shutdown()

关闭资源并释放连接。

Shutdown the runner by calling the adapter's shutdown method.

返回Returns
无返回值。a CompletableFuture that completes when shutdown is done
源码Source io/agentscope/runtime/engine/Runner.java:105–108

streamQuery

public Flux<Event> streamQuery(AgentRequest request)

执行查询。

Stream query by delegating to the adapter.

参数Parameters
名称Name类型Type说明Description
requestAgentRequest智能体请求。the agent request
返回Returns Flux<Event>
返回Flux。a Flux of Event objects with sequence numbers
抛出Throws
  • IllegalStateException 可能抛出 `IllegalStateException`。if the runner is not healthy or framework type is invalid
  • RuntimeException 可能抛出 `RuntimeException`。if framework type is invalid or not set
源码Source io/agentscope/runtime/engine/Runner.java:134–246

isHealthy

public boolean isHealthy()

判断是否 isHealthy。

Check if the runner is healthy.

返回Returns boolean
返回布尔值,表示判断结果。true if healthy, false otherwise
源码Source io/agentscope/runtime/engine/Runner.java:264–266

getAgent

public AgentHandler getAgent()

获取智能体。

Get the underlying adapter.

返回Returns AgentHandler
AgentAdapter 实例。the AgentAdapter instance
源码Source io/agentscope/runtime/engine/Runner.java:273–275

getSandboxService

public SandboxService getSandboxService()

获取沙箱服务。

Returns the sandbox service.

返回Returns SandboxService
返回SandboxService。Returns sandbox service.
源码Source io/agentscope/runtime/engine/Runner.java:277–279
基于官方固定版本源码静态生成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.