feat: make summarization message threshold and token percent configurable (#854) (#1029)

Co-authored-by: Rahul Bansal <rahul@hudle.in>
This commit is contained in:
Rahul BansalandRahul Bansal authored and GitHub committed 2026-03-04 11:23:01 +08:00
1 parent b075ee43d8
commit df1b53fdf9
5 files changed
+71 -41

No files matched your search

+2 -2
View File
@@ -1081,9 +1081,9 @@ func (al *AgentLoop) updateToolContexts(agent *AgentInstance, channel, chatID st
func (al *AgentLoop) maybeSummarize(agent *AgentInstance, sessionKey, channel, chatID string) {
newHistory := agent.Sessions.GetHistory(sessionKey)
tokenEstimate := al.estimateTokens(newHistory)
threshold := agent.ContextWindow * 75 / 100
threshold := agent.ContextWindow * agent.SummarizeTokenPercent / 100
if len(newHistory) > 20 || tokenEstimate > threshold {
if len(newHistory) > agent.SummarizeMessageThreshold || tokenEstimate > threshold {
summarizeKey := agent.ID + ":" + sessionKey
if _, loading := al.summarizing.LoadOrStore(summarizeKey, true); !loading {
go func() {