Class PIIDetectionHook

java.lang.Object
com.alibaba.cloud.ai.graph.agent.hook.messages.MessagesModelHook
com.alibaba.cloud.ai.graph.agent.hook.pii.PIIDetectionHook
All Implemented Interfaces:
Hook, Prioritized

public class PIIDetectionHook extends MessagesModelHook
Detect and handle Personally Identifiable Information (PII) in agent conversations. This hook detects common PII types and applies configurable strategies to handle them. It can detect emails, credit cards, IP addresses, MAC addresses, and URLs in both user input and agent output. Example: PIIDetectionHook pii = PIIDetectionHook.builder() .piiType(PIIType.EMAIL) .strategy(RedactionStrategy.REDACT) .applyToInput(true) .build();
  • Method Details

    • builder

      public static PIIDetectionHook.Builder builder()
    • beforeModel

      public AgentCommand beforeModel(List<org.springframework.ai.chat.messages.Message> previousMessages, RunnableConfig config)
      Overrides:
      beforeModel in class MessagesModelHook
    • afterModel

      public AgentCommand afterModel(List<org.springframework.ai.chat.messages.Message> previousMessages, RunnableConfig config)
      Overrides:
      afterModel in class MessagesModelHook
    • getName

      public String getName()
      Description copied from interface: Hook
      Gets the unique name of this hook. The name is used to identify the hook in the execution graph.
      Returns:
      the hook name, must not be null
    • canJumpTo

      public List<JumpTo> canJumpTo()
      Description copied from interface: Hook
      Gets the list of allowed jump destinations for this hook.

      Hooks can control the flow of execution by specifying where the agent can jump to after the hook executes. This allows hooks to redirect the execution flow based on their logic.

      Common jump destinations include:

      Returns:
      list of allowed jump destinations, empty list by default
      See Also: