fix(context): show both summarize and compress thresholds in /context
The /context command previously showed only the hard budget compression threshold (contextWindow - maxTokens), which confused users who expected to see the soft summarization trigger from summarize_token_percent. This commit adds SummarizeAtTokens alongside the existing CompressAtTokens so that both thresholds are visible: - Compress at: contextWindow - maxTokens (hard budget, triggers proactive compression when exceeded) - Summarize at: contextWindow * summarizeTokenPercent / 100 (soft trigger, matches maybeSummarize's threshold) The fix updates the /context command output, the Web UI popover, and the pico channel WebSocket payload. Fixes #2968
This commit is contained in:
1 parent
709c8b2b52
commit
5f826f4448
9 files changed
+57
-24
No files matched your search
@@ -61,6 +61,13 @@ func computeContextUsage(agent *AgentInstance, sessionKey string) *bus.ContextUs
|
||||
// proactive trigger (msgTokens + toolTokens + maxTokens > contextWindow).
|
||||
compressAt := effectiveWindow
|
||||
|
||||
// summarizeAt = soft summarization trigger: matches maybeSummarize's
|
||||
// threshold (contextWindow * SummarizeTokenPercent / 100).
|
||||
summarizeAt := contextWindow * agent.SummarizeTokenPercent / 100
|
||||
if summarizeAt <= 0 {
|
||||
summarizeAt = compressAt
|
||||
}
|
||||
|
||||
usedPercent := 0
|
||||
if compressAt > 0 {
|
||||
usedPercent = usedTokens * 100 / compressAt
|
||||
@@ -70,9 +77,10 @@ func computeContextUsage(agent *AgentInstance, sessionKey string) *bus.ContextUs
|
||||
}
|
||||
|
||||
return &bus.ContextUsage{
|
||||
UsedTokens: usedTokens,
|
||||
TotalTokens: contextWindow,
|
||||
CompressAtTokens: compressAt,
|
||||
UsedPercent: usedPercent,
|
||||
UsedTokens: usedTokens,
|
||||
TotalTokens: contextWindow,
|
||||
CompressAtTokens: compressAt,
|
||||
SummarizeAtTokens: summarizeAt,
|
||||
UsedPercent: usedPercent,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user