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 Bansal
2026-03-04 08:53:01 +05:30
committed by GitHub
parent b075ee43d8
commit df1b53fdf9
5 changed files with 71 additions and 41 deletions
+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() {