AS AgentScopeAPI 手册 / API Reference

AgentHandler

public interface AgentHandler
源码Source io/agentscope/runtime/adapters/AgentHandler.java:38–149

定义智能体处理器契约的接口。位于 io.agentscope.runtime.adapters 包。核心成员包括 getSandboxService、getName、getDescription、getFrameworkType、start、streamQuery。

AgentAdapter interface provides a unified abstraction for AgentApp core capabilities.

This interface is designed to adapt different Agent Framework Types (e.g., AgentScope, Spring AI Alibaba, Langchain4j) and provides the core lifecycle management and query processing capabilities.

Lifecycle flow:

  • #start() - Start the adapter and mark it as ready

  • #streamQuery(AgentRequest, Object) - Process queries (can be called multiple times)

  • #stop() - Stop accepting new queries

方法摘要Method Summary

方法Method说明Description
public SandboxService getSandboxService()
获取沙箱服务。
Returns the sandbox service.
public String getName()
获取名称。
Returns the name.
public String getDescription()
获取 `getDescription`。
Returns the description.
public String getFrameworkType()
获取 `getFrameworkType`。
Get the framework type this adapter supports.
public void start()
执行启动相关操作。
Start the adapter and mark it as ready to process queries.
public Flux<?> streamQuery(AgentRequest request, Object messages)
执行查询。
Process an agent query and return a stream of framework-specific events.
public void stop()
执行停止相关操作。
Stop the adapter and prevent it from accepting new queries.
public boolean isHealthy()
判断是否 `isHealthy`。
Check if the adapter is in a healthy/ready state.
public StreamAdapter getStreamAdapter()
获取流适配器。
Get the StreamAdapter implementation for this framework adapter.
public MessageAdapter getMessageAdapter()
获取消息适配器。
Get the MessageAdapter implementation for this framework adapter.

方法详情Method Detail

getSandboxService

public SandboxService getSandboxService()

获取沙箱服务。

Returns the sandbox service.

返回Returns SandboxService
返回SandboxService。Returns sandbox service.
源码Source io/agentscope/runtime/adapters/AgentHandler.java:39

getName

public String getName()

获取名称。

Returns the name.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/adapters/AgentHandler.java:41

getDescription

public String getDescription()

获取 getDescription。

Returns the description.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/adapters/AgentHandler.java:43

getFrameworkType

public String getFrameworkType()

获取 getFrameworkType。

Get the framework type this adapter supports.

返回Returns String
返回字符串结果。the framework type string
源码Source io/agentscope/runtime/adapters/AgentHandler.java:52

start

public void start()

执行启动相关操作。

Start the adapter and mark it as ready to process queries.

源码Source io/agentscope/runtime/adapters/AgentHandler.java:62

streamQuery

public Flux<?> streamQuery(AgentRequest request, Object messages)

执行查询。

Process an agent query and return a stream of framework-specific events.

参数Parameters
名称Name类型Type说明Description
requestAgentRequest请求(类型 `AgentRequest`)。the agent request containing input messages, session info, etc.
messagesObject消息列表(类型 `Object`)。the converted framework-specific messages (e.g., List for agentscope), or null if no conversion is needed
返回Returns Flux<?>
返回Flux。a Flux of framework-specific Event objects (e.g., Flux for agentscope)
抛出Throws
  • IllegalStateException 当if 适配器是不已启动时抛出 `IllegalStateException`。if the adapter is not started
  • RuntimeException 可能抛出 `RuntimeException`。if the query handler is not set or encounters an error
源码Source io/agentscope/runtime/adapters/AgentHandler.java:95

stop

public void stop()

执行停止相关操作。

Stop the adapter and prevent it from accepting new queries.

源码Source io/agentscope/runtime/adapters/AgentHandler.java:104

isHealthy

public boolean isHealthy()

判断是否 isHealthy。

Check if the adapter is in a healthy/ready state.

返回Returns boolean
返回布尔值,表示判断结果。true if the adapter is healthy and ready, false otherwise
源码Source io/agentscope/runtime/adapters/AgentHandler.java:115

getStreamAdapter

public StreamAdapter getStreamAdapter()

获取流适配器。

Get the StreamAdapter implementation for this framework adapter.

返回Returns StreamAdapter
返回StreamAdapter。the StreamAdapter implementation for this framework, or null if streaming is not supported
源码Source io/agentscope/runtime/adapters/AgentHandler.java:132

getMessageAdapter

public MessageAdapter getMessageAdapter()

获取消息适配器。

Get the MessageAdapter implementation for this framework adapter.

返回Returns MessageAdapter
返回MessageAdapter。the MessageAdapter implementation for this framework
源码Source io/agentscope/runtime/adapters/AgentHandler.java:148
基于官方固定版本源码静态生成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.