feat: add TokenTracker for managing token usage, costs, and context.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user