Class AguiStateConverter

java.lang.Object
io.agentscope.core.agui.converter.AguiStateConverter

public class AguiStateConverter extends Object
Converter for state management in the AG-UI protocol.

This class handles the creation of state events (snapshots and deltas) from AgentScope's state system.

  • Constructor Details

    • AguiStateConverter

      public AguiStateConverter()
  • Method Details

    • createSnapshot

      public AguiEvent.StateSnapshot createSnapshot(Map<String,Object> state, String threadId, String runId)
      Create a STATE_SNAPSHOT event from a state map.
      Parameters:
      state - The state map
      threadId - The thread ID
      runId - The run ID
      Returns:
      The StateSnapshot event
    • createDelta

      public AguiEvent.StateDelta createDelta(Map<String,Object> before, Map<String,Object> after, String threadId, String runId)
      Create a STATE_DELTA event by comparing before and after states.

      This method generates JSON Patch operations (RFC 6902) that can transform the "before" state into the "after" state.

      Parameters:
      before - The state before changes
      after - The state after changes
      threadId - The thread ID
      runId - The run ID
      Returns:
      The StateDelta event, or null if there are no changes
    • hasChanges

      public boolean hasChanges(Map<String,Object> before, Map<String,Object> after)
      Check if there are any differences between two states.
      Parameters:
      before - The state before changes
      after - The state after changes
      Returns:
      true if there are differences