usageHasTokens reports whether any billable tokens were recorded for a turn. Used to suppress the missing-price warning for empty/no-op turns.
(usage *chat.Usage)
| 1080 | // usageHasTokens reports whether any billable tokens were recorded for a turn. |
| 1081 | // Used to suppress the missing-price warning for empty/no-op turns. |
| 1082 | func usageHasTokens(usage *chat.Usage) bool { |
| 1083 | if usage == nil { |
| 1084 | return false |
| 1085 | } |
| 1086 | return usage.InputTokens > 0 || |
| 1087 | usage.OutputTokens > 0 || |
| 1088 | usage.CachedInputTokens > 0 || |
| 1089 | usage.CacheWriteTokens > 0 |
| 1090 | } |
| 1091 | |
| 1092 | // compactIfNeeded estimates the token impact of tool results added since |
| 1093 | // messageCountBefore and triggers proactive compaction when the estimated |
no outgoing calls