Class AguiRestController

java.lang.Object
io.agentscope.spring.boot.agui.mvc.AguiRestController

@RestController public class AguiRestController extends Object
REST controller for AG-UI protocol endpoints.

This controller exposes the AG-UI run endpoints for Spring MVC applications. It delegates the actual processing to AguiMvcController.

  • Constructor Summary

    Constructors
    Constructor
    Description
    AguiRestController(AguiMvcController aguiMvcController, String pathPrefix, boolean enablePathRouting, io.agentscope.core.agui.runtime.AguiRequestBodyParser requestBodyParser)
    Creates a new AguiRestController.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<String>
    handleParseError(io.agentscope.core.util.JsonException error)
    Return HTTP 400 for AG-UI request body parsing failures.
    org.springframework.web.servlet.mvc.method.annotation.SseEmitter
    run(String body, String agentIdHeader, jakarta.servlet.http.HttpServletRequest request)
    Handle an AG-UI run request.
    org.springframework.web.servlet.mvc.method.annotation.SseEmitter
    runWithAgentId(String agentId, String body, String agentIdHeader, jakarta.servlet.http.HttpServletRequest request)
    Handle an AG-UI run request with agent ID in the URL path.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AguiRestController

      public AguiRestController(AguiMvcController aguiMvcController, String pathPrefix, boolean enablePathRouting, io.agentscope.core.agui.runtime.AguiRequestBodyParser requestBodyParser)
      Creates a new AguiRestController.
      Parameters:
      aguiMvcController - The AG-UI MVC controller
      pathPrefix - The path prefix for endpoints
      enablePathRouting - Whether to enable path variable routing
      requestBodyParser - The parser used to decode request bodies
  • Method Details

    • run

      @PostMapping(value="${agentscope.agui.path-prefix:/agui}/run", consumes="application/json", produces="text/event-stream") public org.springframework.web.servlet.mvc.method.annotation.SseEmitter run(@RequestBody String body, @RequestHeader(value="${agentscope.agui.agent-id-header:X-Agent-Id}",required=false) String agentIdHeader, jakarta.servlet.http.HttpServletRequest request)
      Handle an AG-UI run request.

      Agent ID is resolved from (in priority order):

      1. HTTP header (configurable, default: X-Agent-Id)
      2. forwardedProps.agentId in request body
      3. config.defaultAgentId
      4. "default"
      Parameters:
      body - The raw run agent input JSON
      agentIdHeader - The agent ID from HTTP header (optional)
      Returns:
      An SseEmitter for streaming AG-UI events
    • runWithAgentId

      @PostMapping(value="${agentscope.agui.path-prefix:/agui}/run/{agentId}", consumes="application/json", produces="text/event-stream") public org.springframework.web.servlet.mvc.method.annotation.SseEmitter runWithAgentId(@PathVariable String agentId, @RequestBody String body, @RequestHeader(value="${agentscope.agui.agent-id-header:X-Agent-Id}",required=false) String agentIdHeader, jakarta.servlet.http.HttpServletRequest request)
      Handle an AG-UI run request with agent ID in the URL path.

      The path variable takes highest priority for agent resolution.

      Parameters:
      agentId - The agent ID from path variable
      body - The raw run agent input JSON
      agentIdHeader - The agent ID from HTTP header (optional)
      Returns:
      An SseEmitter for streaming AG-UI events
    • handleParseError

      @ExceptionHandler(io.agentscope.core.util.JsonException.class) public org.springframework.http.ResponseEntity<String> handleParseError(io.agentscope.core.util.JsonException error)
      Return HTTP 400 for AG-UI request body parsing failures.
      Parameters:
      error - the JSON parse failure
      Returns:
      an SSE-compatible bad request response