Class LargeResultEvictionInterceptor
java.lang.Object
com.alibaba.cloud.ai.graph.agent.interceptor.ToolInterceptor
com.alibaba.cloud.ai.graph.agent.extension.interceptor.LargeResultEvictionInterceptor
- All Implemented Interfaces:
Interceptor
Tool interceptor that automatically evicts large tool results to the filesystem.
This interceptor monitors tool call responses and when they exceed a configurable
token limit, it automatically saves the full result to a file and returns a truncated
message with a pointer to the file location.
Key Features (from Python's FilesystemMiddleware.wrap_tool_call):
- Automatic detection of large results (>20000 tokens by default)
- Eviction to /large_tool_results/ directory
- Content sample (first 10 lines) included in response
- Exclusion of filesystem tools (they handle their own results)
- Tool call ID sanitization for safe file paths
Example:
LargeResultEvictionInterceptor interceptor = LargeResultEvictionInterceptor.builder()
.toolTokenLimitBeforeEvict(20000)
.excludeTools(Set.of("ls", "read_file", "write_file"))
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for LargeResultEvictionInterceptor. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()getName()interceptToolCall(ToolCallRequest request, ToolCallHandler handler) Wrap a tool call with custom logic.
-
Method Details
-
builder
-
getName
-
interceptToolCall
Description copied from class:ToolInterceptorWrap 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.- Specified by:
interceptToolCallin classToolInterceptor- Parameters:
request- The tool call requesthandler- The next handler in the chain (or base handler)- Returns:
- The tool call response
-