Class StudioMessageHook

java.lang.Object
io.agentscope.core.studio.StudioMessageHook
All Implemented Interfaces:
io.agentscope.core.hook.Hook

public class StudioMessageHook extends Object implements io.agentscope.core.hook.Hook
Hook for automatically forwarding agent messages to Studio.

This hook intercepts PostCallEvent events (fired after an agent produces a response) and sends the output message to Studio for visualization. If message forwarding fails, the error is logged but does not interrupt agent execution.

Usage:


 ReActAgent agent = ReActAgent.builder()
     .name("Assistant")
     .model(model)
     .hook(new StudioMessageHook(studioClient))
     .build();
 
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new Studio message hook.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends io.agentscope.core.hook.HookEvent>
    reactor.core.publisher.Mono<T>
    onEvent(T event)
    Handles hook events.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.agentscope.core.hook.Hook

    priority, tools
  • Constructor Details

    • StudioMessageHook

      public StudioMessageHook(StudioClient studioClient)
      Creates a new Studio message hook.
      Parameters:
      studioClient - The Studio HTTP client for sending messages
  • Method Details

    • onEvent

      public <T extends io.agentscope.core.hook.HookEvent> reactor.core.publisher.Mono<T> onEvent(T event)
      Handles hook events.

      This method listens for PostCallEvent and forwards the agent's output message to Studio. Other event types are passed through unchanged.

      Specified by:
      onEvent in interface io.agentscope.core.hook.Hook
      Type Parameters:
      T - The event type
      Parameters:
      event - The hook event to process
      Returns:
      A Mono that emits the event (possibly after async processing)