Class SummarizationHook
java.lang.Object
com.alibaba.cloud.ai.graph.agent.hook.ModelHook
com.alibaba.cloud.ai.graph.agent.hook.summarization.SummarizationHook
- All Implemented Interfaces:
Hook
Hook that summarizes conversation history when token limits are approached.
This hook monitors message token counts and automatically summarizes older
messages when a threshold is reached, preserving recent messages and maintaining
context continuity.
Example:
SummarizationHook summarizer = SummarizationHook.builder()
.model(chatModel)
.maxTokensBeforeSummary(4000)
.messagesToKeep(20)
.build();
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbeforeModel(OverAllState state, RunnableConfig config) static SummarizationHook.Builderbuilder()getName()Methods inherited from class com.alibaba.cloud.ai.graph.agent.hook.ModelHook
afterModel, getAgentName, setAgentNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.alibaba.cloud.ai.graph.agent.hook.Hook
getHookPositions, getKeyStrategys
-
Method Details
-
builder
-
beforeModel
- Overrides:
beforeModelin classModelHook
-
getName
-
canJumpTo
-