Class AdkWebServer.AgentController

java.lang.Object
com.google.adk.web.AdkWebServer.AgentController
Enclosing class:
AdkWebServer

@RestController public static class AdkWebServer.AgentController extends Object
Spring Boot REST Controller handling agent-related API endpoints.
  • Constructor Details

    • AgentController

      @Autowired public AgentController(BaseSessionService sessionService, BaseArtifactService artifactService, @Qualifier("loadedAgentRegistry") Map<String, BaseAgent> agentRegistry, AdkWebServer.ApiServerSpanExporter apiServerSpanExporter, AdkWebServer.RunnerService runnerService)
      Constructs the AgentController.
      Parameters:
      sessionService - The service for managing sessions.
      artifactService - The service for managing artifacts.
      agentRegistry - The registry of loaded agents.
      apiServerSpanExporter - The exporter holding all trace data.
      runnerService - The service for obtaining Runner instances.
  • Method Details

    • listApps

      @GetMapping("/list-apps") public List<String> listApps()
      Lists available applications. Currently returns only the configured root agent's name.
      Returns:
      A list containing the root agent's name.
    • getTraceDict

      @GetMapping("/debug/trace/{eventId}") public org.springframework.http.ResponseEntity<?> getTraceDict(@PathVariable String eventId)
      Endpoint for retrieving trace information stored by the ApiServerSpanExporter, based on event ID.
      Parameters:
      eventId - The ID of the event to trace (expected to be gcp.vertex.agent.event_id).
      Returns:
      A ResponseEntity containing the trace data or NOT_FOUND.
    • getSessionTrace

      @GetMapping("/debug/trace/session/{sessionId}") public org.springframework.http.ResponseEntity<Object> getSessionTrace(@PathVariable String sessionId)
      Retrieves trace spans for a given session ID.
      Parameters:
      sessionId - The session ID.
      Returns:
      A ResponseEntity containing a list of span data maps for the session, or an empty list.
    • getSession

      @GetMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}") public Session getSession(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId)
      Retrieves a specific session by its ID.
      Parameters:
      appName - The application name.
      userId - The user ID.
      sessionId - The session ID.
      Returns:
      The requested Session object.
      Throws:
      org.springframework.web.server.ResponseStatusException - if the session is not found.
    • listSessions

      @GetMapping("/apps/{appName}/users/{userId}/sessions") public List<Session> listSessions(@PathVariable String appName, @PathVariable String userId)
      Lists all non-evaluation sessions for a given app and user.
      Parameters:
      appName - The name of the application.
      userId - The ID of the user.
      Returns:
      A list of sessions, excluding those used for evaluation.
    • createSessionWithId

      @PostMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}") public Session createSessionWithId(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId, @RequestBody(required=false) Map<String,Object> state)
      Creates a new session with a specific ID provided by the client.
      Parameters:
      appName - The application name.
      userId - The user ID.
      sessionId - The desired session ID.
      state - Optional initial state for the session.
      Returns:
      The newly created Session object.
      Throws:
      org.springframework.web.server.ResponseStatusException - if a session with the given ID already exists (BAD_REQUEST) or if creation fails (INTERNAL_SERVER_ERROR).
    • createSession

      @PostMapping("/apps/{appName}/users/{userId}/sessions") public Session createSession(@PathVariable String appName, @PathVariable String userId, @RequestBody(required=false) Map<String,Object> state)
      Creates a new session where the ID is generated by the service.
      Parameters:
      appName - The application name.
      userId - The user ID.
      state - Optional initial state for the session.
      Returns:
      The newly created Session object.
      Throws:
      org.springframework.web.server.ResponseStatusException - if creation fails (INTERNAL_SERVER_ERROR).
    • deleteSession

      @DeleteMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}") public org.springframework.http.ResponseEntity<Void> deleteSession(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId)
      Deletes a specific session.
      Parameters:
      appName - The application name.
      userId - The user ID.
      sessionId - The session ID to delete.
      Returns:
      A ResponseEntity with status NO_CONTENT on success.
      Throws:
      org.springframework.web.server.ResponseStatusException - if deletion fails (INTERNAL_SERVER_ERROR).
    • loadArtifact

      @GetMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}/artifacts/{artifactName}") public com.google.genai.types.Part loadArtifact(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId, @PathVariable String artifactName, @RequestParam(required=false) Integer version)
      Loads the latest or a specific version of an artifact associated with a session.
      Parameters:
      appName - The application name.
      userId - The user ID.
      sessionId - The session ID.
      artifactName - The name of the artifact.
      version - Optional specific version number. If null, loads the latest.
      Returns:
      The artifact content as a Part object.
      Throws:
      org.springframework.web.server.ResponseStatusException - if the artifact is not found (NOT_FOUND).
    • loadArtifactVersion

      @GetMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}/artifacts/{artifactName}/versions/{versionId}") public com.google.genai.types.Part loadArtifactVersion(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId, @PathVariable String artifactName, @PathVariable int versionId)
      Loads a specific version of an artifact.
      Parameters:
      appName - The application name.
      userId - The user ID.
      sessionId - The session ID.
      artifactName - The name of the artifact.
      versionId - The specific version number.
      Returns:
      The artifact content as a Part object.
      Throws:
      org.springframework.web.server.ResponseStatusException - if the artifact version is not found (NOT_FOUND).
    • listArtifactNames

      @GetMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}/artifacts") public List<String> listArtifactNames(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId)
      Lists the names of all artifacts associated with a session.
      Parameters:
      appName - The application name.
      userId - The user ID.
      sessionId - The session ID.
      Returns:
      A list of artifact names.
    • listArtifactVersions

      @GetMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}/artifacts/{artifactName}/versions") public List<Integer> listArtifactVersions(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId, @PathVariable String artifactName)
      Lists the available versions for a specific artifact.
      Parameters:
      appName - The application name.
      userId - The user ID.
      sessionId - The session ID.
      artifactName - The name of the artifact.
      Returns:
      A list of version numbers (integers).
    • deleteArtifact

      @DeleteMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}/artifacts/{artifactName}") public org.springframework.http.ResponseEntity<Void> deleteArtifact(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId, @PathVariable String artifactName)
      Deletes an artifact and all its versions.
      Parameters:
      appName - The application name.
      userId - The user ID.
      sessionId - The session ID.
      artifactName - The name of the artifact to delete.
      Returns:
      A ResponseEntity with status NO_CONTENT on success.
      Throws:
      org.springframework.web.server.ResponseStatusException - if deletion fails (INTERNAL_SERVER_ERROR).
    • agentRun

      @PostMapping("/run") public List<Event> agentRun(@RequestBody AdkWebServer.AgentRunRequest request)
      Executes a non-streaming agent run for a given session and message.
      Parameters:
      request - The AgentRunRequest containing run details.
      Returns:
      A list of events generated during the run.
      Throws:
      org.springframework.web.server.ResponseStatusException - if the session is not found or the run fails.
    • agentRunSse

      @PostMapping(value="/run_sse", produces="text/event-stream") public org.springframework.web.servlet.mvc.method.annotation.SseEmitter agentRunSse(@RequestBody AdkWebServer.AgentRunRequest request)
      Executes an agent run and streams the resulting events using Server-Sent Events (SSE).
      Parameters:
      request - The AgentRunRequest containing run details.
      Returns:
      A Flux that will stream events to the client.
    • getEventGraph

      @GetMapping("/apps/{appName}/users/{userId}/sessions/{sessionId}/events/{eventId}/graph") public org.springframework.http.ResponseEntity<AdkWebServer.GraphResponse> getEventGraph(@PathVariable String appName, @PathVariable String userId, @PathVariable String sessionId, @PathVariable String eventId)
      Endpoint to get a graph representation of an event (currently returns a placeholder). Requires Graphviz or similar tooling for full implementation.
      Parameters:
      appName - Application name.
      userId - User ID.
      sessionId - Session ID.
      eventId - Event ID.
      Returns:
      ResponseEntity containing a GraphResponse with placeholder DOT source.
      Throws:
      org.springframework.web.server.ResponseStatusException - if the session or event is not found.
    • createEvalSet

      @PostMapping("/apps/{appName}/eval_sets/{evalSetId}") public org.springframework.http.ResponseEntity<Object> createEvalSet(@PathVariable String appName, @PathVariable String evalSetId)
      Placeholder for creating an evaluation set.
    • listEvalSets

      @GetMapping("/apps/{appName}/eval_sets") public List<String> listEvalSets(@PathVariable String appName)
      Placeholder for listing evaluation sets.
    • addSessionToEvalSet

      @PostMapping("/apps/{appName}/eval_sets/{evalSetId}/add-session") public org.springframework.http.ResponseEntity<Object> addSessionToEvalSet(@PathVariable String appName, @PathVariable String evalSetId, @RequestBody AdkWebServer.AddSessionToEvalSetRequest req)
      Placeholder for adding a session to an evaluation set.
    • listEvalsInEvalSet

      @GetMapping("/apps/{appName}/eval_sets/{evalSetId}/evals") public List<String> listEvalsInEvalSet(@PathVariable String appName, @PathVariable String evalSetId)
      Placeholder for listing evaluations within an evaluation set.
    • runEval

      @PostMapping("/apps/{appName}/eval_sets/{evalSetId}/run-eval") public List<AdkWebServer.RunEvalResult> runEval(@PathVariable String appName, @PathVariable String evalSetId, @RequestBody AdkWebServer.RunEvalRequest req)
      Placeholder for running evaluations.
    • getEvalResult

      @GetMapping("/apps/{appName}/eval_results/{evalResultId}") public org.springframework.http.ResponseEntity<Object> getEvalResult(@PathVariable String appName, @PathVariable String evalResultId)
      Gets a specific evaluation result. (STUB - Not Implemented)
      Parameters:
      appName - The application name.
      evalResultId - The evaluation result ID.
      Returns:
      A ResponseEntity indicating the endpoint is not implemented.
    • listEvalResults

      @GetMapping("/apps/{appName}/eval_results") public List<String> listEvalResults(@PathVariable String appName)
      Lists all evaluation results for an app. (STUB - Not Implemented)
      Parameters:
      appName - The application name.
      Returns:
      An empty list, as this endpoint is not implemented.