AgentHandler
public interface AgentHandler
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.
SandboxServiceio/agentscope/runtime/adapters/AgentHandler.java:39getName
public String getName()
获取名称。
Returns the name.
Stringio/agentscope/runtime/adapters/AgentHandler.java:41getDescription
public String getDescription()
获取 getDescription。
Returns the description.
Stringio/agentscope/runtime/adapters/AgentHandler.java:43getFrameworkType
public String getFrameworkType()
获取 getFrameworkType。
Get the framework type this adapter supports.
Stringio/agentscope/runtime/adapters/AgentHandler.java:52start
public void start()
执行启动相关操作。
Start the adapter and mark it as ready to process queries.
io/agentscope/runtime/adapters/AgentHandler.java:62streamQuery
public Flux<?> streamQuery(AgentRequest request, Object messages)
执行查询。
Process an agent query and return a stream of framework-specific events.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
request | AgentRequest | 请求(类型 `AgentRequest`)。the agent request containing input messages, session info, etc. |
messages | Object | 消息列表(类型 `Object`)。the converted framework-specific messages (e.g., List for agentscope), or null if no conversion is needed |
Flux<?>IllegalStateException当if 适配器是不已启动时抛出 `IllegalStateException`。if the adapter is not startedRuntimeException可能抛出 `RuntimeException`。if the query handler is not set or encounters an error
io/agentscope/runtime/adapters/AgentHandler.java:95stop
public void stop()
执行停止相关操作。
Stop the adapter and prevent it from accepting new queries.
io/agentscope/runtime/adapters/AgentHandler.java:104isHealthy
public boolean isHealthy()
判断是否 isHealthy。
Check if the adapter is in a healthy/ready state.
booleanio/agentscope/runtime/adapters/AgentHandler.java:115getStreamAdapter
public StreamAdapter getStreamAdapter()
获取流适配器。
Get the StreamAdapter implementation for this framework adapter.
StreamAdapterio/agentscope/runtime/adapters/AgentHandler.java:132getMessageAdapter
public MessageAdapter getMessageAdapter()
获取消息适配器。
Get the MessageAdapter implementation for this framework adapter.
MessageAdapterio/agentscope/runtime/adapters/AgentHandler.java:148