| 17 | } |
| 18 | |
| 19 | func BuildContextWindowSnapshot(cfg config.Config, state *agent.AgentState) ContextWindowSnapshot { |
| 20 | used := 0 |
| 21 | if state != nil { |
| 22 | used = agentContext.TokenCountWithEstimation(state.Messages) |
| 23 | if state.SystemPrompt != "" { |
| 24 | used += agentContext.RoughEstimate(state.SystemPrompt) |
| 25 | } |
| 26 | } |
| 27 | return ContextWindowSnapshot{ |
| 28 | ModelName: cfg.APIModel, |
| 29 | UsedTokens: used, |
| 30 | LimitTokens: cfg.CompressionContextLimit(), |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | func FormatContextWindowStatus(model string, usedTokens, limitTokens int, width int) string { |
| 35 | if width <= 0 { |