Class StudioClient

java.lang.Object
io.agentscope.core.studio.StudioClient

public class StudioClient extends Object
HTTP client for communicating with AgentScope Studio.

This client handles HTTP requests to Studio's REST API endpoints using OkHttp. It provides methods for registering runs, pushing messages, and requesting user input. All operations are reactive and return Mono types for integration with Project Reactor.

The client includes automatic retry logic for failed requests (configurable via StudioConfig).

  • Constructor Details

    • StudioClient

      public StudioClient(StudioConfig config)
      Creates a new Studio HTTP client.
      Parameters:
      config - Configuration for Studio connection
  • Method Details

    • registerRun

      public reactor.core.publisher.Mono<Void> registerRun()
      Registers a new run with Studio.

      This must be called before sending any messages. It notifies Studio that a new agent application is starting up.

      POST /trpc/registerRun

      Returns:
      A Mono that completes when registration succeeds
    • pushMessage

      public reactor.core.publisher.Mono<Void> pushMessage(io.agentscope.core.message.Msg msg)
      Pushes a message to Studio for visualization.

      This method is typically called automatically by StudioMessageHook after an agent produces a response. It includes retry logic for robustness.

      POST /trpc/pushMessage

      Parameters:
      msg - The message to push
      Returns:
      A Mono that completes when the message is successfully pushed
    • requestUserInput

      public reactor.core.publisher.Mono<String> requestUserInput(String agentId, String agentName, Object structuredSchema)
      Requests user input from Studio web interface.

      This sends a request to Studio, which displays an input form to the user in the web UI. The actual input will be received via WebSocket (see StudioWebSocketClient).

      POST /trpc/requestUserInput

      Parameters:
      agentId - ID of the agent requesting input
      agentName - Name of the agent requesting input
      structuredSchema - Optional JSON schema for structured input
      Returns:
      A Mono containing the request ID (used to match WebSocket response)
    • shutdown

      public void shutdown()
      Shuts down the HTTP client and releases resources.