Class ModelInterceptor

java.lang.Object
com.alibaba.cloud.ai.graph.agent.interceptor.ModelInterceptor
All Implemented Interfaces:
Interceptor
Direct Known Subclasses:
ContextEditingInterceptor, FilesystemInterceptor, ModelFallbackInterceptor, PatchToolCallsInterceptor, SubAgentInterceptor, TodoListInterceptor, ToolSelectionInterceptor

public abstract class ModelInterceptor extends Object implements Interceptor
Model interceptor that can wrap model calls. Implementations can modify requests, responses, or add behavior like retry, fallback, etc.
  • Constructor Details

    • ModelInterceptor

      public ModelInterceptor()
  • Method Details

    • interceptModel

      public abstract ModelResponse interceptModel(ModelRequest request, ModelCallHandler handler)
      Wrap a model call with custom logic. Implementations can: - Modify the request before calling the handler - Call the handler multiple times (retry logic) - Modify the response after handler returns - Handle exceptions and provide fallbacks
      Parameters:
      request - The model request
      handler - The next handler in the chain (or base handler)
      Returns:
      The model response
    • getTools

      public List<org.springframework.ai.tool.ToolCallback> getTools()
      Get tools provided by this interceptor. Interceptors can provide built-in tools that will be automatically added to the agent.
      Returns:
      List of tools provided by this interceptor, empty list by default