1
0

feat: add TokenTracker for managing token usage, costs, and context.

This commit is contained in:
2026-03-04 12:11:39 +01:00
parent c6b87a5ce7
commit 928ca8c454

View File

@@ -37,15 +37,15 @@ internal sealed class TokenTracker
/// <summary>
/// Returns true if the context is getting too large and should be compacted.
/// Triggers at min(75% of model context, 100K tokens).
/// Triggers at min(75% of model context, 150K tokens).
/// </summary>
public bool ShouldCompact()
{
if (LastInputTokens <= 0) return false;
int threshold = ContextLength > 0
? Math.Min((int)(ContextLength * 0.75), 100_000)
: 100_000;
? Math.Min((int)(ContextLength * 0.75), 150_000)
: 150_000;
return LastInputTokens >= threshold;
}