Class InterceptorChain

java.lang.Object
com.alibaba.cloud.ai.graph.agent.interceptor.InterceptorChain

public class InterceptorChain extends Object
Utility class for chaining model and tool interceptors. This implements the Chain of Responsibility pattern. Interceptors are composed so that the first in the list becomes the outermost layer.
  • Constructor Details

    • InterceptorChain

      public InterceptorChain()
  • Method Details

    • chainModelInterceptors

      public static ModelCallHandler chainModelInterceptors(List<ModelInterceptor> interceptors, ModelCallHandler baseHandler)
      Chain multiple ModelInterceptors into a single handler. The first interceptor wraps all others, creating a nested structure: interceptors[0] -> interceptors[1] -> ... -> base handler
      Parameters:
      interceptors - List of ModelInterceptors to chain
      baseHandler - The base handler that executes the actual model call
      Returns:
      A composed handler, or the base handler if no interceptors
    • chainToolInterceptors

      public static ToolCallHandler chainToolInterceptors(List<ToolInterceptor> interceptors, ToolCallHandler baseHandler)
      Chain multiple ToolInterceptors into a single handler. The first interceptor wraps all others, creating a nested structure: interceptors[0] -> interceptors[1] -> ... -> base handler
      Parameters:
      interceptors - List of ToolInterceptors to chain
      baseHandler - The base handler that executes the actual tool call
      Returns:
      A composed handler, or the base handler if no interceptors