AS AgentScopeAPI 手册 / API Reference

A2aController

@RestController @RequestMapping("/a2a") public class A2aController
源码Source io/agentscope/runtime/protocol/a2a/controller/A2aController.java:45–176

A 2 a 控制器,支持智能体之间的发现、委派与协作。位于 io.agentscope.runtime.protocol.a2a.controller 包。核心成员包括 handleRequest、isStreamingRequest、handleStreamRequest、handleNonStreamRequest、A2aController。

A class in io.agentscope.runtime.protocol.a2a.controller that supports discovery, delegation and collaboration between agents. Declared in io.agentscope.runtime.protocol.a2a.controller.

构造器摘要Constructor Summary

构造器Constructor说明Description
public A2aController(Runner runner, AgentCard agentCard, ObjectProvider<ProtocolConfig> protocolConfigs)
初始化 `A2aController` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public Object handleRequest(String body, HttpServletRequest httpRequest)
处理请求。
Performs the handle request operation.
protected boolean isStreamingRequest(String requestBody, ServerCallContext context)
判断是否流式请求。
Returns whether the streaming request.
protected Flux<ServerSentEvent<String>> handleStreamRequest(String body, ServerCallContext context) throws JsonProcessingException
处理流请求。
Performs the handle stream request operation.
protected JSONRPCResponse<?> handleNonStreamRequest(String body, ServerCallContext context) throws JsonProcessingException
处理 `handleNonStreamRequest`。
Performs the handle non stream request operation.

构造器详情Constructor Detail

A2aController

public A2aController(Runner runner, AgentCard agentCard, ObjectProvider<ProtocolConfig> protocolConfigs)

初始化 A2aController 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
runnerRunner运行器(类型 `Runner`)。The runner.
agentCardAgentCard智能体卡片(类型 `AgentCard`)。The agent card.
protocolConfigsObjectProvider<ProtocolConfig>协议 Configs(类型 `ObjectProvider`)。The protocol configs.
源码Source io/agentscope/runtime/protocol/a2a/controller/A2aController.java:53–55

方法详情Method Detail

handleRequest

public Object handleRequest(String body, HttpServletRequest httpRequest)

处理请求。

Performs the handle request operation.

参数Parameters
名称Name类型Type说明Description
bodyString正文(类型 `String`)。The body.
httpRequestHttpServletRequestHTTP 请求(类型 `HttpServletRequest`)。The http request.
返回Returns Object
返回对象。Returns object.
源码Source io/agentscope/runtime/protocol/a2a/controller/A2aController.java:57–78

isStreamingRequest

protected boolean isStreamingRequest(String requestBody, ServerCallContext context)

判断是否流式请求。

Returns whether the streaming request.

参数Parameters
名称Name类型Type说明Description
requestBodyString请求正文(类型 `String`)。The request body.
contextServerCallContext上下文(类型 `ServerCallContext`)。The context.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/runtime/protocol/a2a/controller/A2aController.java:80–95

handleStreamRequest

protected Flux<ServerSentEvent<String>> handleStreamRequest(String body, ServerCallContext context) throws JsonProcessingException

处理流请求。

Performs the handle stream request operation.

参数Parameters
名称Name类型Type说明Description
bodyString正文(类型 `String`)。The body.
contextServerCallContext上下文(类型 `ServerCallContext`)。The context.
返回Returns Flux<ServerSentEvent<String>>
返回Flux>。Returns flux.
抛出Throws
  • JsonProcessingException 可能抛出 `JsonProcessingException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/runtime/protocol/a2a/controller/A2aController.java:97–111

handleNonStreamRequest

protected JSONRPCResponse<?> handleNonStreamRequest(String body, ServerCallContext context) throws JsonProcessingException

处理 handleNonStreamRequest。

Performs the handle non stream request operation.

参数Parameters
名称Name类型Type说明Description
bodyString正文(类型 `String`)。The body.
contextServerCallContext上下文(类型 `ServerCallContext`)。The context.
返回Returns JSONRPCResponse<?>
返回JSONRPCResponse。Returns JSON RPC response.
抛出Throws
  • JsonProcessingException 可能抛出 `JsonProcessingException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/runtime/protocol/a2a/controller/A2aController.java:137–157
基于官方固定版本源码静态生成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.