Class AguiRequestProcessor
java.lang.Object
io.agentscope.core.agui.processor.AguiRequestProcessor
Core processor for AG-UI requests.
This class encapsulates the common logic for processing AG-UI requests, extracting it from MVC and WebFlux handlers to avoid code duplication.
Responsibilities:
- Agent ID resolution from multiple sources
- Message extraction for server-side memory scenarios
- Agent resolution via
AgentResolver - Event stream generation via
AguiAgentAdapter
Usage:
AguiRequestProcessor processor = AguiRequestProcessor.builder()
.agentResolver(resolver)
.config(AguiAdapterConfig.defaultConfig())
.build();
ProcessResult result = processor.process(input, headerAgentId, pathAgentId);
Flux<AguiEvent> events = result.events();
Agent agent = result.agent(); // For interrupt handling
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for AguiRequestProcessor.static final recordResult of processing an AG-UI request. -
Method Summary
Modifier and TypeMethodDescriptionstatic AguiRequestProcessor.Builderbuilder()Creates a new builder for AguiRequestProcessor.Extract only the latest user message from the input.process(RunAgentInput input, String headerAgentId, String pathAgentId) Process an AG-UI request and return the result containing agent and event stream.resolveAgentId(RunAgentInput input, String headerAgentId, String pathAgentId) Resolve the agent ID from multiple sources.
-
Method Details
-
process
public AguiRequestProcessor.ProcessResult process(RunAgentInput input, String headerAgentId, String pathAgentId) Process an AG-UI request and return the result containing agent and event stream.- Parameters:
input- The run agent inputheaderAgentId- The agent ID from HTTP header (may be null)pathAgentId- The agent ID from URL path variable (may be null)- Returns:
- A ProcessResult containing the agent and event stream
-
resolveAgentId
Resolve the agent ID from multiple sources.The agent ID is resolved in the following priority order:
- URL path variable (if provided)
- HTTP header (if provided)
- forwardedProps.agentId in request body
- config.defaultAgentId
- "default"
- Parameters:
input- The request inputheaderAgentId- The agent ID from HTTP header (may be null)pathAgentId- The agent ID from URL path variable (may be null)- Returns:
- The resolved agent ID
-
extractLatestUserMessage
Extract only the latest user message from the input.This is used when server-side memory is enabled and the agent already has conversation history. Only the latest user message needs to be passed.
- Parameters:
input- The original input- Returns:
- A new input with only the latest user message
-
builder
Creates a new builder for AguiRequestProcessor.- Returns:
- A new builder instance
-