Class ContextEditingInterceptor
java.lang.Object
com.alibaba.cloud.ai.graph.agent.interceptor.ModelInterceptor
com.alibaba.cloud.ai.graph.agent.interceptor.contextediting.ContextEditingInterceptor
- All Implemented Interfaces:
Interceptor
Context editing interceptor that clears older tool results once the conversation
grows beyond a configurable token threshold.
This mirrors Anthropic's context editing capabilities by managing tool result
history to stay within token limits.
Example:
ContextEditingInterceptor interceptor = ContextEditingInterceptor.builder()
.trigger(100000)
.keep(3)
.clearAtLeast(1000)
.build();
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbuilder()getName()interceptModel(ModelRequest request, ModelCallHandler handler) Wrap a model call with custom logic.Methods inherited from class com.alibaba.cloud.ai.graph.agent.interceptor.ModelInterceptor
getTools
-
Method Details
-
builder
-
interceptModel
Description copied from class:ModelInterceptorWrap 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- Specified by:
interceptModelin classModelInterceptor- Parameters:
request- The model requesthandler- The next handler in the chain (or base handler)- Returns:
- The model response
-
getName
-