Class AguiWebFluxHandler
java.lang.Object
io.agentscope.spring.boot.agui.webflux.AguiWebFluxHandler
WebFlux handler for AG-UI protocol requests.
This handler processes AG-UI run requests and returns Server-Sent Events (SSE) streams with AG-UI protocol events.
Agent ID Resolution Priority:
- URL path variable:
/agui/run/{agentId} - HTTP header: configurable via
agentIdHeader(default: X-Agent-Id) - forwardedProps.agentId in request body
- config.defaultAgentId
- "default"
Usage:
AguiWebFluxHandler handler = AguiWebFluxHandler.builder()
.agentRegistry(registry)
.config(AguiAdapterConfig.defaultConfig())
.agentIdHeader("X-Agent-Id")
.build();
RouterFunction<ServerResponse> routes = RouterFunctions.route()
.POST("/agui/run", handler::handle)
.POST("/agui/run/{agentId}", handler::handleWithAgentId)
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for AguiWebFluxHandler. -
Method Summary
Modifier and TypeMethodDescriptionstatic AguiWebFluxHandler.Builderbuilder()Creates a new builder for AguiWebFluxHandler.reactor.core.publisher.Mono<org.springframework.web.reactive.function.server.ServerResponse> handle(org.springframework.web.reactive.function.server.ServerRequest request) Handle an AG-UI run request.reactor.core.publisher.Mono<org.springframework.web.reactive.function.server.ServerResponse> handleWithAgentId(org.springframework.web.reactive.function.server.ServerRequest request) Handle an AG-UI run request with agent ID in the URL path.
-
Method Details
-
handle
public reactor.core.publisher.Mono<org.springframework.web.reactive.function.server.ServerResponse> handle(org.springframework.web.reactive.function.server.ServerRequest request) Handle an AG-UI run request.This method parses the request body as
RunAgentInput, resolves the agent from the registry, and returns an SSE stream of AG-UI events.- Parameters:
request- The server request- Returns:
- A Mono containing the server response with SSE stream
-
handleWithAgentId
public reactor.core.publisher.Mono<org.springframework.web.reactive.function.server.ServerResponse> handleWithAgentId(org.springframework.web.reactive.function.server.ServerRequest request) Handle an AG-UI run request with agent ID in the URL path.This method handles requests to
/agui/run/{agentId}. The path variable takes highest priority for agent resolution.- Parameters:
request- The server request containing the agentId path variable- Returns:
- A Mono containing the server response with SSE stream
-
builder
Creates a new builder for AguiWebFluxHandler.- Returns:
- A new builder instance
-