Class ToolInterceptor

java.lang.Object
com.alibaba.cloud.ai.graph.agent.interceptor.ToolInterceptor
All Implemented Interfaces:
Interceptor
Direct Known Subclasses:
LargeResultEvictionInterceptor, ToolEmulatorInterceptor, ToolErrorInterceptor, ToolRetryInterceptor

public abstract class ToolInterceptor extends Object implements Interceptor
Tool interceptor that can wrap tool calls. Implementations can modify requests, responses, or add behavior like retry, caching, etc.
  • Constructor Details

    • ToolInterceptor

      public ToolInterceptor()
  • Method Details

    • interceptToolCall

      public abstract ToolCallResponse interceptToolCall(ToolCallRequest request, ToolCallHandler handler)
      Wrap a tool 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 - Add caching, logging, monitoring, etc.
      Parameters:
      request - The tool call request
      handler - The next handler in the chain (or base handler)
      Returns:
      The tool call response